| | |
WxGlade does not show value
![]() |
If I run the following code the textCtrl's aren't updated, they stay empty, but if I do
Why isn't it update !!
print self.extra201.GetValue() I get the value that is set with the code beneath. Python Syntax (Toggle Plain Text)
self.extra101.SetValue(names[1]) self.extra201.SetValue(names[2]) self.extra111.SetValue(str(money[1])) self.extra211.SetValue(str(money[2]))
Why isn't it update !!
0
#3 14 Days Ago
In that case I get the errors:
Python Syntax (Toggle Plain Text)
(python:25618): Gtk-CRITICAL **: gtk_entry_buffer_insert_text: assertion `GTK_IS_ENTRY_BUFFER (buffer)' failed (python:25618): Gtk-CRITICAL **: gtk_entry_buffer_insert_text: assertion `GTK_IS_ENTRY_BUFFER (buffer)' failed (python:25618): Gtk-CRITICAL **: gtk_entry_buffer_insert_text: assertion `GTK_IS_ENTRY_BUFFER (buffer)' failed (python:25618): Gtk-CRITICAL **: gtk_entry_buffer_insert_text: assertion `GTK_IS_ENTRY_BUFFER (buffer)' failed
0
#5 14 Days Ago
Do You mean I have to give whole my code and/or a screenshot of my wxglade window?
Or will you even with that not be able to help me?
Or will you even with that not be able to help me?
•
•
Join Date: Dec 2006
Posts: 995
Reputation:
Solved Threads: 281
0
#6 14 Days Ago
Do you have to use something like queue_draw() to update the widget? The pygtk.org site has been down for 2 days now, so can't look it up, but try it and see.
Just write a simple program using whatever type of widget it is, label, entry box, etc., and update the text in some way. There may be a problem with the way you are coding it, but it may also be that the list "name" is empty. In whatever case, a simple program to illustrate will work fine.
And if you did not get the color change or set widow size answers. Check line 30 and 61 in this code found somewhere on the web at some time in the past.
•
•
•
•
Do You mean I have to give whole my code and/or a screenshot of my wxglade window?
And if you did not get the color change or set widow size answers. Check line 30 and 61 in this code found somewhere on the web at some time in the past.
Python Syntax (Toggle Plain Text)
import pygtk pygtk.require('2.0') import gtk class HelloWorld2: # Our new improved callback. The data passed to this method # is printed to stdout. def callback(self, widget, data): print "Hello again - %s was pressed" % data # another callback def delete_event(self, widget, event, data=None): gtk.main_quit() return False def __init__(self): # Create a new window self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) # This is a new call, which just sets the title of our # new window to "Hello Buttons!" self.window.set_title("Hello Buttons!") width = 200 height = 100 self.window.set_size_request(width, height) # Here we just set a handler for delete_event that immediately # exits GTK. self.window.connect("delete_event", self.delete_event) # Sets the border width of the window. self.window.set_border_width(10) # We create a box to pack widgets into. This is described in detail # in the "packing" section. The box is not really visible, it # is just used as a tool to arrange widgets. self.box1 = gtk.HBox(False, 0) # Put the box into the main window. self.window.add(self.box1) # Creates a new button with the label "Button 1". self.button1 = gtk.Button("Button 1") # Now when the button is clicked, we call the "callback" method # with a pointer to "button 1" as its argument self.button1.connect("clicked", self.callback, "button 1") # Instead of add(), we pack this button into the invisible # box, which has been packed into the window. self.box1.pack_start(self.button1, True, True, 0) # Always remember this step, this tells GTK that our preparation for # this button is complete, and it can now be displayed. self.button1.show() # Do these same steps again to create a second button self.button2 = gtk.Button("Button 2") self.button2.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("blue")) # Call the same callback method with a different argument, # passing a pointer to "button 2" instead. self.button2.connect("clicked", self.callback, "button 2") self.box1.pack_start(self.button2, True, True, 0) # The order in which we show the buttons is not really important, but I # recommend showing the window last, so it all pops up at once. self.button2.show() self.box1.show() self.window.show() if __name__ == "__main__": hello = HelloWorld2() gtk.main()
Last edited by woooee; 14 Days Ago at 12:59 pm.
Linux counter #99383
0
#7 14 Days Ago
What do you mean with "WxGlade does not show value"?
Is it WxGlade or your program you wrote using WxGlade?
Just a note on the smart side of things. If you have a problem for others to look at and possible solve, it behooves you to supply as much needed information as you can. Otherwise buzz off and don't waste everyone's time.
Is it WxGlade or your program you wrote using WxGlade?
Just a note on the smart side of things. If you have a problem for others to look at and possible solve, it behooves you to supply as much needed information as you can. Otherwise buzz off and don't waste everyone's time.
Last edited by sneekula; 14 Days Ago at 3:41 pm.
No one died when Clinton lied.
0
#8 14 Days Ago
@woee: I did exactly the same in an other program and there wxglade does change!
P.S. it's wxpython not pygtk
@sneekula: I made a program with wxglade, I added some functions in the code, but when I ran the script the entry values are not updated like I thought they would...
P.S. it's wxpython not pygtk
@sneekula: I made a program with wxglade, I added some functions in the code, but when I ran the script the entry values are not updated like I thought they would...
Python Syntax (Toggle Plain Text)
#!/usr/bin/env python # -*- coding: utf-8 -*- # generated by wxGlade 0.6.3 on Sat Nov 7 12:15:47 2009 import wx # begin wxGlade: extracode # end wxGlade class game(wx.Frame): def __init__(self, *args, **kwds): # begin wxGlade: game.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.extra10 = wx.StaticText(self, -1, "Name") self.extra101 = wx.TextCtrl(self, -1, "") self.extra11 = wx.StaticText(self, -1, "Money") self.extra111 = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY) self.extra30 = wx.StaticText(self, -1, "Jackpot") self.extra301 = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY) self.extra20 = wx.StaticText(self, -1, "Name") self.extra201 = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY) self.extra21 = wx.StaticText(self, -1, "Money") self.extra211 = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY) self.info10 = wx.StaticText(self, -1, "Name") self.info11 = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY) self.info20 = wx.StaticText(self, -1, "Owned by") self.info21 = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY) self.info30 = wx.StaticText(self, -1, "extra") self.info31 = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY) self.nextturn = wx.Button(self, -1, "Next Turn") self.buybutton = wx.Button(self, -1, "Buy") self.otherbutton = wx.Button(self, -1, "Other") # Menu Bar self.menubar2 = wx.MenuBar() self.SetMenuBar(self.menubar2) # Menu Bar end self.status = self.CreateStatusBar(1, 0) self.__set_properties() self.__do_layout() self.Bind(wx.EVT_BUTTON, self.next_turn, self.nextturn) self.Bind(wx.EVT_BUTTON, self.buy, self.buybutton) # end wxGlade global names global money def __set_properties(self): # begin wxGlade: game.__set_properties self.SetTitle("frame_2") self.buybutton.Enable(False) self.otherbutton.Enable(False) self.status.SetStatusWidths([-1]) # statusbar fields status_fields = ["frame_2_statusbar"] for i in range(len(status_fields)): self.status.SetStatusText(status_fields[i], i) # end wxGlade def __do_layout(self): # begin wxGlade: game.__do_layout sizer_2 = wx.BoxSizer(wx.VERTICAL) sizer_3 = wx.BoxSizer(wx.VERTICAL) sizer_6 = wx.BoxSizer(wx.HORIZONTAL) sizer_7 = wx.BoxSizer(wx.HORIZONTAL) sizer_10 = wx.BoxSizer(wx.HORIZONTAL) sizer_9 = wx.BoxSizer(wx.HORIZONTAL) sizer_8 = wx.BoxSizer(wx.HORIZONTAL) grid_sizer_4 = wx.GridSizer(10, 10, 0, 0) sizer_4 = wx.BoxSizer(wx.HORIZONTAL) grid_sizer_3 = wx.GridSizer(2, 2, 0, 0) sizer_5 = wx.BoxSizer(wx.HORIZONTAL) grid_sizer_2 = wx.GridSizer(2, 2, 0, 0) grid_sizer_2.Add(self.extra10, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) grid_sizer_2.Add(self.extra101, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) grid_sizer_2.Add(self.extra11, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) grid_sizer_2.Add(self.extra111, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) sizer_4.Add(grid_sizer_2, 1, wx.EXPAND, 0) sizer_5.Add(self.extra30, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) sizer_5.Add(self.extra301, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) sizer_4.Add(sizer_5, 1, wx.EXPAND, 0) grid_sizer_3.Add(self.extra20, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) grid_sizer_3.Add(self.extra201, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) grid_sizer_3.Add(self.extra21, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) grid_sizer_3.Add(self.extra211, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) sizer_4.Add(grid_sizer_3, 1, wx.EXPAND, 0) sizer_3.Add(sizer_4, 1, wx.EXPAND, 0) sizer_3.Add(grid_sizer_4, 1, wx.EXPAND, 0) sizer_8.Add(self.info10, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) sizer_8.Add(self.info11, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) sizer_7.Add(sizer_8, 1, wx.EXPAND, 0) sizer_9.Add(self.info20, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) sizer_9.Add(self.info21, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) sizer_7.Add(sizer_9, 1, wx.EXPAND, 0) sizer_10.Add(self.info30, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) sizer_10.Add(self.info31, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) sizer_7.Add(sizer_10, 1, wx.EXPAND, 0) sizer_3.Add(sizer_7, 1, wx.EXPAND, 0) sizer_6.Add(self.nextturn, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) sizer_6.Add(self.buybutton, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) sizer_6.Add(self.otherbutton, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) sizer_3.Add(sizer_6, 1, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0) sizer_2.Add(sizer_3, 1, wx.EXPAND, 0) self.SetSizer(sizer_2) sizer_2.Fit(self) self.Layout() # end wxGlade def initialize(self): self.turn = 1 self.places = [0,1,1] self.buildings = [[],["Start","Dragopoly","Not Buyable",""],["2","Dragopoly","2","25",10],["3","Dragopoly","3","25",15],["4","Dragopoly","4","25",20],["5","Dragopoly","5","25",25],["6","Dragopoly","6","25",30],["7","Dragopoly","7","25",31],["8","Dragopoly","8","25",32],["9","Dragopoly","9","25",33],["Prison","Dragopoly","Visit",""],["11","Dragopoly","11","25",35],["12","Dragopoly","12","25",40],["13","Dragopoly","13","25",45],["14","Dragopoly","14","25",50],["15","Dragopoly","15","25",55],["16","Dragopoly","13","25",60],["17","Dragopoly","13","25",65],["18","Dragopoly","13","25",70],["19","Dragopoly","13","25",75],["Parking","Dragopoly","Get jackpot",""],["21","Dragopoly","13","25",80],["22","Dragopoly","13","25",85],["23","Dragopoly","13","25",90],["24","Dragopoly","13","25",95],["25","Dragopoly","13","25",100],["26","Dragopoly","13","25",105],["27","Dragopoly","13","25",110],["28","Dragopoly","13","25",115],["29","Dragopoly","13","25",120],["Goto Hospital","Dragopoly","Goto Hospital",""],["31","Dragopoly","13","25",125],["32","Dragopoly","13","25",130],["33","Dragopoly","13","25",135],["34","Dragopoly","13","25",140],["35","Dragopoly","13","25",145],["36","Dragopoly","13","25",150],["37","Dragopoly","13","25",155],["38","Dragopoly","13","25",160],["39","Dragopoly","13","25",165],["Dragopoly Tax","Dragopoly","Pay 200","25",166]] self.owns = [[0],[0],[0]] self.jackpot = 0 self.extra101.WriteText(names[1]) self.extra201.WriteText(names[2]) self.extra111.WriteText(str(money[1])) self.extra211.WriteText(str(money[2])) self.turn = 0 def next_turn(self, event): # wxGlade: game.<event_handler> print "Event handler `next_turn' not implemented!" event.Skip() def buy(self, event): # wxGlade: game.<event_handler> print "Event handler `buy' not implemented!" event.Skip() # end of class game class Main(wx.Frame): def __init__(self, *args, **kwds): # begin wxGlade: Main.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) # Menu Bar self.menubar = wx.MenuBar() wxglade_tmp_menu = wx.Menu() wxglade_tmp_menu.Append(wx.NewId(), "New", "", wx.ITEM_NORMAL) wxglade_tmp_menu.Append(wx.NewId(), "open", "", wx.ITEM_NORMAL) self.menubar.Append(wxglade_tmp_menu, "File") wxglade_tmp_menu = wx.Menu() self.menubar.Append(wxglade_tmp_menu, "Help") self.SetMenuBar(self.menubar) # Menu Bar end self.p1name = wx.StaticText(self, -1, "Player 1 Name:", style=wx.ALIGN_CENTRE) self.p1entry = wx.TextCtrl(self, -1, "") self.p2name = wx.StaticText(self, -1, "Player 2 Name:", style=wx.ALIGN_CENTRE) self.p2entry = wx.TextCtrl(self, -1, "") self.moneystart = wx.StaticText(self, -1, "Money:", style=wx.ALIGN_CENTRE) self.moneyentry = wx.TextCtrl(self, -1, "") self.newgamebutton = wx.Button(self, -1, "start new game") self.newgameinfo = wx.StaticText(self, -1, "Money: the ammount of\n money each player gets\n at the start") self.__set_properties() self.__do_layout() self.Bind(wx.EVT_MENU, self.new_game, id=-1) self.Bind(wx.EVT_BUTTON, self.new_game, self.newgamebutton) # end wxGlade def __set_properties(self): # begin wxGlade: Main.__set_properties self.SetTitle("frame_1") # end wxGlade def __do_layout(self): # begin wxGlade: Main.__do_layout sizer_1 = wx.BoxSizer(wx.VERTICAL) grid_sizer_1 = wx.GridSizer(4, 2, 0, 0) grid_sizer_1.Add(self.p1name, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) grid_sizer_1.Add(self.p1entry, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) grid_sizer_1.Add(self.p2name, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) grid_sizer_1.Add(self.p2entry, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) grid_sizer_1.Add(self.moneystart, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) grid_sizer_1.Add(self.moneyentry, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) grid_sizer_1.Add(self.newgamebutton, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) grid_sizer_1.Add(self.newgameinfo, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) sizer_1.Add(grid_sizer_1, 1, wx.EXPAND, 0) self.SetSizer(sizer_1) sizer_1.Fit(self) self.Layout() # end wxGlade def new_game(self, event): # wxGlade: Main.<event_handler> global names global money names = [0,self.p1entry.GetValue(),self.p2entry.GetValue()] money = [0,int(self.moneyentry.GetValue()),int(self.moneyentry.GetValue())] game(self).Show() Main.Hide(self) game(self).initialize() # end of class Main if __name__ == "__main__": app = wx.PySimpleApp(0) wx.InitAllImageHandlers() frame_1 = Main(None, -1, "") app.SetTopWindow(frame_1) frame_1.Show() app.MainLoop()
![]() |
Similar Threads
- We only give homework help to those who show effort (Computer Science)
- IE won't let site show pictures. (Web Browsers)
- the 2 little computers do not show on the taskbar, connection issue (Windows NT / 2000 / XP)
- Show Hidden Program or System Files (Windows tips 'n' tweaks)
- Show Encrypted Files in Color (Windows tips 'n' tweaks)
- Right click menu slow to show (Windows NT / 2000 / XP)
Other Threads in the Python Forum
- Previous Thread: How can I make a loop that changes?
- Next Thread: Python Question
| Thread Tools | Search this Thread |
alarm ansi app assignment avogadro backend beginner binary bluetooth character cipher cmd customdialog cx-freeze data decimals dictionary directory dynamic error exe file float format function generator getvalue gnu graphics halp heads homework http ideas import input ip itunes java keycontrol leftmouse line linux list lists loop maintain maze millimeter module mouse number numbers output parsing path pointer prime programming progressbar push py2exe pygame python queue random recursion schedule screensaverloopinactive script slicenotation sqlite ssh statistics string strings sudokusolver sum text thread threading time tlapse tuple tutorial ubuntu unicode url urllib urllib2 variable variables ventrilo vigenere web webservice wikipedia write wxpython xlib






