поляна aboutDialog не закрывается

Вы можете просто выполнить то, что вам нужно, без AxisArtist. Если вы можете обойтись без этого, то вот следующий пример кода:

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Circle

fig, ax = plt.subplots(1,1, figsize=(7,7))
ax.add_artist(Circle((0,0),1,color='b'))
ax.set_xlim((-5,5))
ax.set_ylim((-5,5))

plt.show()

EDIT: повторить с AxisArtist

import matplotlib.pyplot as plt
import mpl_toolkits.axisartist as AA
%matplotlib "notebook"

fig = plt.figure(1, figsize=(5,5))
ax = AA.Subplot(fig, 1, 1, 1)
fig.add_subplot(ax)
centreCircle = plt.Circle((0, 0), 1, color="black", fill=False, lw=2)
ax.add_patch(centreCircle)
ax.set_ylim(-5, 5)
ax.set_xlim(-5, 5)
plt.show()
plt.savefig('circle5x5v2.png')

enter image description here

5
задан Gilles Gouaillardet 10 January 2018 в 02:29
поделиться

2 ответа

Необходимо звонить, виджет скрывают () метод, когда Вы получаете, удаляют или сигналы аннулирования:

response = self.wTree.get_widget("aboutdialog1").run() # or however you run it
if response == gtk.RESPONSE_DELETE_EVENT or response == gtk.RESPONSE_CANCEL:
  self.wTree.get_widget("aboutdialog1").hide()

Можно найти константы Типа Ответа в документации GTK

5
ответ дан 13 December 2019 в 19:36
поделиться

As any other Dialog window, they require you to

  1. Make use of the run method.
  2. Make use of the "reponse" signal

The first will block the main loop and will return as soon as the dialog receives a response, this may be, click on any button in the action area or press Esc, or call the dialog's response method or "destroy" the window, the last don't mean that the window wil be destroyed, this means that the run() method will exit and return a response. like this:

response = dialog.run()

If you use a debugger, you will notice that the main loop stays there until you click on a button or try to close the dialog. Once you have received yout response, then you can useit as you want.

response = dialog.run()
if response == gtk.RESPONSE_OK:
    #do something here if the user hit the OK button 
dialog.destroy()

The second allow you to use the dialog in a non-blocking stuff, then you have to connect your dialog to the "response" signal.

def do_response(dialog, response):
    if response == gtk.RESPONSE_OK:
        #do something here if the user hit the OK button 
    dialog.destroy()

dialog.connect('response', do_response)

Now, you notice that you have to destroy your dialog

6
ответ дан 13 December 2019 в 19:36
поделиться