close
Python Forum
[WxPython] how to run the dialog from another py file
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WxPython] how to run the dialog from another py file
#1
this my code, how do you think I would?
class MainFrame(wx.Frame):
    """"""

    #----------------------------------------------------------------------
    def __init__(self):
        """Constructor"""
        wx.Frame.__init__(self, None, title="Test")
        panel = wx.Panel(self)

        btn = wx.Button(panel, label="Ask Question")
        btn.Bind(wx.EVT_BUTTON, self.showMessageDlg)

    #----------------------------------------------------------------------
    def showMessageDlg(self, event):
        dial()  #execute of other py file


if __name__ == "__main__":
    app = wx.App(False)
    frame = MainFrame()
    frame.Show()
    app.MainLoop()
dial.py
"""
        Show a message
        """
        msg = "Do you want to continue?"
        title = "Question!"
        style =  wx.YES_NO|wx.YES_DEFAULT|wx.ICON_QUESTION
        dlg = wx.MessageDialog(parent=None, message=msg, 
                               caption=title, style=style)
        result = dlg.ShowModal()
        if result == wx.ID_YES:
            print "User pressed yes!"
        else:
            print "User pressed no!"
        dlg.Destroy()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [WxPython] [SOLVED] Simple dialog without app? Winfried 5 1,412 Oct-07-2025, 02:30 PM
Last Post: Winfried
Smile [Tkinter] Trying to make Fond Dialog box TheTiger 11 4,146 Oct-16-2024, 01:56 AM
Last Post: menator01
  How a QMainWindow can open a dialog? panoss 4 6,893 Feb-03-2022, 04:33 PM
Last Post: panoss
  [Tkinter] question for a tkinter dialog box RobertAlvarez424 2 3,696 Aug-25-2021, 03:08 PM
Last Post: RobertAlvarez424
  [Tkinter] cancelling open dialog gives empty string rwahdan 2 6,053 Jul-17-2021, 09:17 PM
Last Post: steve_shambles
  [WxPython] Return code when closing the dialog ioprst 1 4,571 Aug-13-2019, 11:47 AM
Last Post: jefsummers
  PyQT5 : Unable to Create Another Dialog While One is Open iMuny 3 6,271 Jul-17-2019, 11:40 AM
Last Post: iMuny
  [WxPython] Any dialog that allow user to select file OR folder? buran 3 6,695 Apr-03-2019, 06:33 PM
Last Post: Yoriz
  FileBrowser dialog reverendfuzzy 5 7,040 May-06-2018, 01:56 PM
Last Post: reverendfuzzy
  I'm trying to create a simple yes/no dialog box RedSkeleton007 15 28,323 Apr-25-2018, 05:10 PM
Last Post: nilamo

Forum Jump:
Image

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020