Problem using wxPython

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • somialis
    New Member
    • Mar 2007
    • 32

    #16
    Originally posted by bartonc
    I did a test:
    Code:
    #Boa:Frame:Frame2
    
    import wx
    
    def create(parent):
        return Frame1(parent)
    
    [wxID_FRAME1, wxID_FRAME1PANEL1, wxID_FRAME1TEXTCTRL1,
    ] = [wx.NewId() for _init_ctrls in range(3)]
    
    class Frame1(wx.Frame):
        def _init_sizers(self):
            # generated method, don't edit
            self.boxSizer1 = wx.BoxSizer(orient=wx.VERTICAL)
    
            self._init_coll_boxSizer1_Items(self.boxSizer1)
    
            self.SetSizer(self.boxSizer1)
    
    
        def _init_coll_boxSizer1_Items(self, parent):
            # generated method, don't edit
    
            parent.AddWindow(self.panel1, 1, border=0, flag=wx.EXPAND)
    
        def _init_ctrls(self, prnt):
            # generated method, don't edit
            wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt, pos=wx.Point(22, 22),
                    size=wx.Size(400, 250), style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
            self.SetClientSize(wx.Size(392, 223))
    
            self.panel1 = wx.Panel(id=wxID_FRAME1PANEL1, name='panel1', parent=self, pos=wx.Point(0, 0),
                    size=wx.Size(392, 223), style=wx.TAB_TRAVERSAL)
    
            self.textCtrl1 = wx.TextCtrl(id=wxID_FRAME1TEXTCTRL1, name='textCtrl1', parent=self.panel1,
                    pos=wx.Point(16, 72), size=wx.Size(360, 21), style=0, value='')
    
            self._init_sizers()
    
        def __init__(self, parent):
            self._init_ctrls(parent)
    Code:
    #!/usr/bin/env python
    #Boa:App:BoaApp
    
    import wx
    
    import Frame2
    
    modules ={u'Frame2': [1, 'Main frame of Application', u'Frame2.py']}
    
    class BoaApp(wx.App):
        def OnInit(self):
            self.main = Frame2.create(None)
            ## this is NOT good OOP encapulation, but it works ##
            self.main.textCtrl1.SetValue('this is a test')
            #                                                   #
            self.main.Show()
            self.SetTopWindow(self.main)
            return True
    
    def main():
        application = BoaApp(0)
        application.MainLoop()
    
    if __name__ == '__main__':
        main()
    I can set the TextCtrl Value while the app is being initialized.
    Hi,
    This does not serve my purpose. I want to set some value in a box thru my script which wud have ,otherwise,been set by clicking on a browse tab and then selecting a file by a mouse click.

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #17
      Originally posted by somialis
      Hi,
      This does not serve my purpose. I want to set some value in a box thru my script which wud have ,otherwise,been set by clicking on a browse tab and then selecting a file by a mouse click.
      It may not serve your purpose, but it shows you that you should be able to set the Value of a TextCtrl from outside the frame that creates it.

      And since you have not provided the frame to work on, this is the best that I could whip up in order to show you.

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #18
        Originally posted by bartonc
        It may not serve your purpose, but it shows you that you should be able to set the Value of a TextCtrl from outside the frame that creates it.

        And since you have not provided the frame to work on, this is the best that I could whip up in order to show you.
        This may be of interest to you:
        wxApp::argv
        wxChar ** argv

        Command line arguments (after environment-specific processing).

        Comment

        • somialis
          New Member
          • Mar 2007
          • 32

          #19
          Originally posted by bartonc
          This may be of interest to you:
          wxApp::argv
          wxChar ** argv

          Command line arguments (after environment-specific processing).
          hey hi...
          the code snippet u had posted as an example worked. I created a GUI of my own...rather than using the already available one.It's working the way i wanted it to....:)
          thanks!! :)

          Comment

          • bartonc
            Recognized Expert Expert
            • Sep 2006
            • 6478

            #20
            Originally posted by somialis
            hey hi...
            the code snippet u had posted as an example worked. I created a GUI of my own...rather than using the already available one.It's working the way i wanted it to....:)
            thanks!! :)
            That's awesome. I am SO glad that you got it working.

            Thanks for the update,
            Barton

            Comment

            Working...