|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
wxTextCtrl ( )
for some reason my text box does not want to show, but if i was to remove the button then everything is fine.. does anyone know why?
Code:
import os
from wxPython.wx import *
EXIT_ID = 0
ABOUT_ID = 1
FILEP_ID = 2
class myFrame ( wxFrame ):
def __init__ ( self, Parant, Id, Title ):
wxFrame.__init__ ( self, Parant, Id, Title,
wxDefaultPosition, wxSize ( 650, 350 ))
self.dirname = ""
self.control = wxTextCtrl( self, 1, style = wxTE_MULTILINE )
self.CreateStatusBar ( )
self.SetStatusText ( 'Welcome Users' )
self.button = wxButton ( self, 10, "Save", wxPoint ( 2, 275 ))
myMenus = wxMenu ( )
myMenus.Append ( FILEP_ID, '&Open', 'Open a new file' )
myMenus.Append ( ABOUT_ID, '&About', 'About This Program' )
myMenus.Append ( EXIT_ID, '&Exit', 'Exit The Program' )
myMenuBar = wxMenuBar ( )
myMenuBar.Append ( myMenus, '&File' )
self.SetMenuBar ( myMenuBar )
EVT_MENU ( self, FILEP_ID, self.OpenFile )
EVT_MENU ( self, ABOUT_ID, self.AboutFunc )
EVT_MENU ( self, EXIT_ID, self.ExitFunc )
def OpenFile ( self, event ):
FileDialogz = wxFileDialog ( self, 'Chose File', self.dirname,
"", '*.*', wxOPEN )
if FileDialogz.ShowModal ( ) == wxID_OK:
self.filename = FileDialogz.GetFilename ( )
self.dirname = FileDialogz.GetDirectory ( )
fopen = open ( os.path.join ( self.dirname, self.filename ), 'r' )
self.control.SetValue ( fopen.read ( ))
fopen.close ( )
FileDialogz.Destroy ( )
def AboutFunc ( self, event ):
dlg = wxMessageDialog ( self, 'Program Created xlordt',
'About Us', wxOK | wxICON_INFORMATION )
dlg.ShowModal ( )
dlg.Destroy ( )
def ExitFunc ( self, event ):
self.Close ( true )
class MyApp ( wxApp ):
def OnInit ( self ):
frame = myFrame ( NULL, -1, "Xlordt -- Editor" )
frame.Show ( true )
self.SetTopWindow ( frame )
return true
app = MyApp ( 0 )
app.MainLoop ( )
Also when i try opening a file i get the following Code:
Gdk-CRITICAL **: file gdkwindow.c: line 1390 (gdk_window_get_size): assertion `window != NULL' failed.
__________________
IE QUOTE | PHP Manual | Google | C/C++ Compiler | Linux Tutorials | General Stuff Game Dev Last edited by xlordt : May 18th, 2004 at 12:14 PM. |
|
#2
|
|||
|
|||
|
I ran the code you posted and it worked fine on my system - Windows XP, Python 2.3.3 and wxPython 2.4.2.4
Sorry I can't help any further. Dave - The Developers' Coach |
|
#3
|
||||
|
||||
|
i got it working with wxPoint to set the possion on it.. but i have one more question.. if i started status bar on one class how do i send a value to it from another? is that possiable?
|
|
#4
|
|||
|
|||
|
Quote:
wxFrame.GetStatusBar() will return the wxStatusBar object associated with the frame. So long as the other class can get hold of the frame object, it should be able to manipulate the status bar. Dave - The Developers' Coach |
|
#5
|
||||
|
||||
|
I tried it and i get an error,
Code:
TypeError: unbound method GetStatusBar() must be called with Frame instance as first argument (got nothing instead) what im tring to do is.. in wxPanel, once you click on the go button it will show what you entered in wxTextCtrl ( ) in the statusbar Code:
class myPanel ( wxPanel ):
def __init__ ( self, Parant, Id, msg ):
wxPanel.__init__ ( self, Parant, Id, wxDefaultPosition,
wxSize ( 10, 50 ), wxRAISED_BORDER|wxTAB_TRAVERSAL )
wxFrame.GetStatusBar ( )
self.text = wxStaticText ( self, -1, msg, wxPoint ( 0, 5 ))
self.text2 = wxTextCtrl ( self, 1, " ", wxPoint ( 50, 2 ), wxSize ( 300, 20 ))
button = wxButton ( self, CLICK_TEXT, "Go", wxPoint ( 354, 2 ), wxSize ( 50, 20 ))
EVT_BUTTON ( self, CLICK_TEXT, self.onClick )
def onClick ( self, event ):
self.SetStatusText ( event.GetString ( ))
class myFrame ( wxFrame ):
def __init__ ( self, Parant, Id, Title ):
wxFrame.__init__ ( self, Parant, Id, Title,
wxDefaultPosition, wxSize ( 650, 350 ))
self.dirname = ""
self.CreateStatusBar ( )
myMenus = wxMenu ( )
myMenus.Append ( FILEP_ID, '&Open', 'Open a new file' )
myMenus.Append ( ABOUT_ID, '&About', 'About This Program' )
myMenus.Append ( EXIT_ID, '&Exit', 'Exit The Program' )
as you can see the statusbar starts in wxFrame then i tried to call it from wxPanel cause thats where the button is at |
|
#6
|
|||
|
|||
|
Sorry, I should have explained it better. You need to call the function on the object you created from a subclass of wxFrame, not on the wxFrame class itself.
In your example, I presume that the wxFrame object is the parent of the MyPanel class (passed to the constructor as "Parant"). If so, then calling Parant.GetStatusBar() should work. Dave - The Developers' Coach |
|
#7
|
||||
|
||||
|
Ok i got it working the way i want it will Netytan's help, but for some reason GetString ( ) was not working correct so instead i used GetValue ( ) and that worked well for me
thanx |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > wxTextCtrl ( ) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|