python - I've created a GUI using wxPython and the functions aren't executed when I run my app -


i'm using python 2.7 , i'm creating gui specific text editor using wxpython.. i've created these 2 scripts run program: gui.py , app1.py , i've put both of them in single folder.

the problem once run app1.py, opens gui perfectly.. when press buttons, commands i've inserted app1.py aren't executed.. not in terminal simple print ()..


i'm using python "2.7.9"

i can run import wx

and wx.__version__ "3.0.2.0"


so, what's problem code?

is inheritance concept problem?

should use super() fix that? if so, how supposed use it?

the gui.py code:

# -*- coding: utf-8 -*-   ########################################################################### ## python code generated wxformbuilder (version jun 17 2015) ## http://www.wxformbuilder.org/ ## please "not" edit file! ###########################################################################   import wx import wx.xrc ########################################################################### ## class mainframe ###########################################################################  class mainframe ( wx.frame ):      def __init__( self, parent ):         wx.frame.__init__ ( self, parent, id = wx.id_any, title = u"editor_sped_lp", pos = wx.defaultposition, size = wx.size( 320,231 ), style = wx.default_frame_style|wx.system_menu|wx.tab_traversal )          self.setsizehintssz( wx.size( -1,-1 ), wx.size( -1,-1 ) )          bsizer1 = wx.boxsizer( wx.vertical )          self.m_textbox = wx.textctrl( self, wx.id_any, wx.emptystring, wx.defaultposition, wx.defaultsize, wx.te_left|wx.te_readonly )         bsizer1.add( self.m_textbox, 0, wx.all|wx.expand, 5 )          self.m_btn_abrirarq = wx.button( self, wx.id_any, u"abrir arquivo...", wx.defaultposition, wx.defaultsize, 0 )         bsizer1.add( self.m_btn_abrirarq, 0, wx.all, 5 )          self.m_btn_editartxt = wx.button( self, wx.id_any, u"editar .txt", wx.defaultposition, wx.defaultsize, 0 )         bsizer1.add( self.m_btn_editartxt, 0, wx.all, 5 )          self.m_gauge1 = wx.gauge( self, wx.id_any, 100, wx.defaultposition, wx.defaultsize, wx.ga_horizontal )         self.m_gauge1.setvalue( 0 )          bsizer1.add( self.m_gauge1, 0, wx.all, 5 )          self.m_textoprogresso = wx.statictext( self, wx.id_any, u"aguardando arquivo..", wx.point( -1,-1 ), wx.defaultsize, wx.align_centre )         self.m_textoprogresso.wrap( -1 )         bsizer1.add( self.m_textoprogresso, 0, wx.all, 5 )          self.m_btn_ajuda = wx.button( self, wx.id_any, u"ajuda", wx.defaultposition, wx.defaultsize, 0 )         bsizer1.add( self.m_btn_ajuda, 0, wx.all, 5 )           self.setsizer( bsizer1 )         self.layout()          self.centre( wx.both )          # connect events         self.m_btn_abrirarq.bind( wx.evt_button, self.abrirarquivo )         self.m_btn_editartxt.bind( wx.evt_button, self.editartxt )         self.m_btn_ajuda.bind( wx.evt_button, self.janelaajuda )      def __del__( self ):         pass       # virtual event handlers, overide them in derived class     def abrirarquivo( self, event ):         event.skip()      def editartxt( self, event ):         event.skip()      def janelaajuda( self, event ):         event.skip() 

the app1.py code:

# -*- coding: utf-8 -*-   #importing wx files import wx #import newly created gui file import gui  #inherit mainframe created in wxformbuilder , create myframe class myframe(gui.mainframe):     #constructor     def __init__(self, parent):         #initialize parent class         gui.mainframe.__init__(self, parent)      #handlers myframe_mainframe events     def abrirarquivo(self, event):         try:             #abrir filedialog box             openfiledialog = wx.filedialog(self, "open", "", "", "text files (*.txt)|*.txt", wx.fd_open | wx.fd_file_must_exist)             openfiledialog.showmodal()             #salvar o caminho para o arquivo             filepath = openfiledialog.getpath()             #alterar textbox para "arquivo encontrado"              textctrl.setvalue(self, "teste")             statictext.setvalue(self, u"arquivo encontrado..")         except exception:             print "erro_abrir_arquivo"      def editartxt(self, event):         try:             #editar texto             dial = wx.messagedialog(none, "teste", 'ajuda - editor sped', wx.ok)             dial.showmodal()             dial.destroy()         except exception:             print "erro_editar_txt"      def janelaajuda( self, event):         try:             #mostrar janela de ajuda             dial = wx.messagedialog(none, "'1 - apertar o botao 'escolher arquivo' \n2 - selecionar o .txt sped da l.p.\n3 - aguarde o processamento..\n4 - o arquivo editado sera salvo na mesma pasta arquivo selecionado\n5 - fim'", 'ajuda - editor sped', wx.ok)             dial.showmodal()             dial.destroy()         except exception:             print "erro_jan_ajuda"  # run app , render-it continuously class myapp(wx.app):     def oninit(self):         self.frame = myframe(none)         self.settopwindow(self.frame)         self.frame.show(true)         print("wxapp criado com sucesso.")         return true if __name__ == "__main__":     # not redirect stdout gui     app = myapp(redirect=false)     # render gui continuously     app.mainloop()  

for logbook:

as mentioned in comment copied both files in empty folder , buttons seem functional when click them, text in console, file picker window, messagebox.

to begin checking installation issues of wx, check with

import wx print wx.__version__ 

if returns version number wxpython installation.

i'm glad solve copying in plain new folder, maybe import or filename confusion happened, seems work 2 files on own.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -