Taiko2k / GTK4PythonTutorial

GTK4 + Python tutorial with code examples
446 stars 33 forks source link

Please add a Gtk.MessageDialog #10

Open misterhsp opened 1 year ago

misterhsp commented 1 year ago

Please add a Gtk.MessageDialog to e.g. display an error or a hint. And close button.

Thanks ...

misterhsp commented 1 year ago

I tried this, but the dialog does not appear. No error message.

    def error(self, error_msg):
        self.dialog = Gtk.MessageDialog(
             buttons = Gtk.ButtonsType.OK,
             modal = True,
             title = ("Error"),
             text = (error_msg),
             transient_for = self)
        self.dialog.connect('response', lambda d,i: d.destroy())
        self.dialog.show()

There seems to be something missing I think...

...

Taiko2k commented 1 year ago

In a quick test that code above does seem to work for me

misterhsp commented 1 year ago

Not for me, no dialog box appears. I have no idea why.

Am 12.11.22 um 07:58 schrieb Taiko2k:

In a quick test that code above does seem to work for me

— Reply to this email directly, view it on GitHub https://github.com/Taiko2k/GTK4PythonTutorial/issues/10#issuecomment-1312392397, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKGJLRML5VWEE7MIUIEGLRLWH45YPANCNFSM6AAAAAARXZ3ITM. You are receiving this because you authored the thread.Message ID: @.***>

misterhsp commented 1 year ago

Small addendum: I took everything according to your code base. Only the dialog I have searched together.

Am 12.11.22 um 07:58 schrieb Taiko2k:

In a quick test that code above does seem to work for me

— Reply to this email directly, view it on GitHub https://github.com/Taiko2k/GTK4PythonTutorial/issues/10#issuecomment-1312392397, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKGJLRML5VWEE7MIUIEGLRLWH45YPANCNFSM6AAAAAARXZ3ITM. You are receiving this because you authored the thread.Message ID: @.***>

Taiko2k commented 1 year ago

Just to double check, you did call the error() function at some point?

misterhsp commented 1 year ago

Yes, of course.

I will try again tonight after work.

Am 12.11.22 um 14:40 schrieb Taiko2k:

Just to double check, you did call the |error()| function at some point?

— Reply to this email directly, view it on GitHub https://github.com/Taiko2k/GTK4PythonTutorial/issues/10#issuecomment-1312480628, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKGJLRK2BIF6WEQONCG2SKTWH6M6DANCNFSM6AAAAAARXZ3ITM. You are receiving this because you authored the thread.Message ID: @.***>

misterhsp commented 1 year ago

I don't even want to say it, it's my own fault. I had a self.close() in the script where it didn't belong. Now the dialog works.

Sorry for the inconvenience :-)

misterhsp commented 1 year ago

Do you maybe already have an example gtk4 grid?

thanks