944,077 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 673
  • Python RSS
Nov 7th, 2009
-1

WxGlade does not show value

Expand Post »
If I run the following code the textCtrl's aren't updated, they stay empty, but if I do print self.extra201.GetValue() I get the value that is set with the code beneath.

Python Syntax (Toggle Plain Text)
  1. self.extra101.SetValue(names[1])
  2. self.extra201.SetValue(names[2])
  3. self.extra111.SetValue(str(money[1]))
  4. self.extra211.SetValue(str(money[2]))

Why isn't it update !!
Similar Threads
Reputation Points: 25
Solved Threads: 11
Posting Whiz in Training
Kruptein is offline Offline
258 posts
since Sep 2009
Nov 7th, 2009
0
Re: WxGlade does not show value
For a wx.TextCtrl() instance I simply use the WriteText() method.
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Nov 7th, 2009
0
Re: WxGlade does not show value
In that case I get the errors:
Python Syntax (Toggle Plain Text)
  1. (python:25618): Gtk-CRITICAL **: gtk_entry_buffer_insert_text: assertion `GTK_IS_ENTRY_BUFFER (buffer)' failed
  2.  
  3. (python:25618): Gtk-CRITICAL **: gtk_entry_buffer_insert_text: assertion `GTK_IS_ENTRY_BUFFER (buffer)' failed
  4.  
  5. (python:25618): Gtk-CRITICAL **: gtk_entry_buffer_insert_text: assertion `GTK_IS_ENTRY_BUFFER (buffer)' failed
  6.  
  7. (python:25618): Gtk-CRITICAL **: gtk_entry_buffer_insert_text: assertion `GTK_IS_ENTRY_BUFFER (buffer)' failed
Reputation Points: 25
Solved Threads: 11
Posting Whiz in Training
Kruptein is offline Offline
258 posts
since Sep 2009
Nov 7th, 2009
0
Re: WxGlade does not show value
In that case I really don't have enough information of what you have and what you did with it!
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Nov 7th, 2009
0
Re: WxGlade does not show value
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?
Reputation Points: 25
Solved Threads: 11
Posting Whiz in Training
Kruptein is offline Offline
258 posts
since Sep 2009
Nov 7th, 2009
0
Re: WxGlade does not show value
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.

Quote ...
Do You mean I have to give whole my code and/or a screenshot of my wxglade window?
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.
Python Syntax (Toggle Plain Text)
  1. import pygtk
  2. pygtk.require('2.0')
  3. import gtk
  4.  
  5. class HelloWorld2:
  6.  
  7. # Our new improved callback. The data passed to this method
  8. # is printed to stdout.
  9. def callback(self, widget, data):
  10. print "Hello again - %s was pressed" % data
  11.  
  12. # another callback
  13. def delete_event(self, widget, event, data=None):
  14. gtk.main_quit()
  15. return False
  16.  
  17. def __init__(self):
  18. # Create a new window
  19. self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
  20.  
  21. # This is a new call, which just sets the title of our
  22. # new window to "Hello Buttons!"
  23. self.window.set_title("Hello Buttons!")
  24. width = 200
  25. height = 100
  26. self.window.set_size_request(width, height)
  27.  
  28. # Here we just set a handler for delete_event that immediately
  29. # exits GTK.
  30. self.window.connect("delete_event", self.delete_event)
  31.  
  32. # Sets the border width of the window.
  33. self.window.set_border_width(10)
  34.  
  35. # We create a box to pack widgets into. This is described in detail
  36. # in the "packing" section. The box is not really visible, it
  37. # is just used as a tool to arrange widgets.
  38. self.box1 = gtk.HBox(False, 0)
  39.  
  40. # Put the box into the main window.
  41. self.window.add(self.box1)
  42.  
  43. # Creates a new button with the label "Button 1".
  44. self.button1 = gtk.Button("Button 1")
  45.  
  46. # Now when the button is clicked, we call the "callback" method
  47. # with a pointer to "button 1" as its argument
  48. self.button1.connect("clicked", self.callback, "button 1")
  49.  
  50. # Instead of add(), we pack this button into the invisible
  51. # box, which has been packed into the window.
  52. self.box1.pack_start(self.button1, True, True, 0)
  53.  
  54. # Always remember this step, this tells GTK that our preparation for
  55. # this button is complete, and it can now be displayed.
  56. self.button1.show()
  57.  
  58. # Do these same steps again to create a second button
  59. self.button2 = gtk.Button("Button 2")
  60. self.button2.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("blue"))
  61.  
  62. # Call the same callback method with a different argument,
  63. # passing a pointer to "button 2" instead.
  64. self.button2.connect("clicked", self.callback, "button 2")
  65.  
  66. self.box1.pack_start(self.button2, True, True, 0)
  67.  
  68. # The order in which we show the buttons is not really important, but I
  69. # recommend showing the window last, so it all pops up at once.
  70. self.button2.show()
  71. self.box1.show()
  72. self.window.show()
  73.  
  74.  
  75. if __name__ == "__main__":
  76. hello = HelloWorld2()
  77. gtk.main()
Last edited by woooee; Nov 7th, 2009 at 12:59 pm.
Reputation Points: 741
Solved Threads: 692
Nearly a Posting Maven
woooee is online now Online
2,307 posts
since Dec 2006
Nov 7th, 2009
0
Re: WxGlade does not show value
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.
Last edited by sneekula; Nov 7th, 2009 at 3:41 pm.
Reputation Points: 961
Solved Threads: 211
Nearly a Posting Maven
sneekula is offline Offline
2,413 posts
since Oct 2006
Nov 7th, 2009
0
Re: WxGlade does not show value
@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...

Python Syntax (Toggle Plain Text)
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # generated by wxGlade 0.6.3 on Sat Nov 7 12:15:47 2009
  4.  
  5. import wx
  6.  
  7. # begin wxGlade: extracode
  8. # end wxGlade
  9.  
  10. class game(wx.Frame):
  11. def __init__(self, *args, **kwds):
  12. # begin wxGlade: game.__init__
  13. kwds["style"] = wx.DEFAULT_FRAME_STYLE
  14. wx.Frame.__init__(self, *args, **kwds)
  15. self.extra10 = wx.StaticText(self, -1, "Name")
  16. self.extra101 = wx.TextCtrl(self, -1, "")
  17. self.extra11 = wx.StaticText(self, -1, "Money")
  18. self.extra111 = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
  19. self.extra30 = wx.StaticText(self, -1, "Jackpot")
  20. self.extra301 = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
  21. self.extra20 = wx.StaticText(self, -1, "Name")
  22. self.extra201 = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
  23. self.extra21 = wx.StaticText(self, -1, "Money")
  24. self.extra211 = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
  25. self.info10 = wx.StaticText(self, -1, "Name")
  26. self.info11 = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
  27. self.info20 = wx.StaticText(self, -1, "Owned by")
  28. self.info21 = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
  29. self.info30 = wx.StaticText(self, -1, "extra")
  30. self.info31 = wx.TextCtrl(self, -1, "", style=wx.TE_READONLY)
  31. self.nextturn = wx.Button(self, -1, "Next Turn")
  32. self.buybutton = wx.Button(self, -1, "Buy")
  33. self.otherbutton = wx.Button(self, -1, "Other")
  34.  
  35. # Menu Bar
  36. self.menubar2 = wx.MenuBar()
  37. self.SetMenuBar(self.menubar2)
  38. # Menu Bar end
  39. self.status = self.CreateStatusBar(1, 0)
  40.  
  41. self.__set_properties()
  42. self.__do_layout()
  43.  
  44. self.Bind(wx.EVT_BUTTON, self.next_turn, self.nextturn)
  45. self.Bind(wx.EVT_BUTTON, self.buy, self.buybutton)
  46. # end wxGlade
  47.  
  48. global names
  49. global money
  50.  
  51. def __set_properties(self):
  52. # begin wxGlade: game.__set_properties
  53. self.SetTitle("frame_2")
  54. self.buybutton.Enable(False)
  55. self.otherbutton.Enable(False)
  56. self.status.SetStatusWidths([-1])
  57. # statusbar fields
  58. status_fields = ["frame_2_statusbar"]
  59. for i in range(len(status_fields)):
  60. self.status.SetStatusText(status_fields[i], i)
  61. # end wxGlade
  62.  
  63. def __do_layout(self):
  64. # begin wxGlade: game.__do_layout
  65. sizer_2 = wx.BoxSizer(wx.VERTICAL)
  66. sizer_3 = wx.BoxSizer(wx.VERTICAL)
  67. sizer_6 = wx.BoxSizer(wx.HORIZONTAL)
  68. sizer_7 = wx.BoxSizer(wx.HORIZONTAL)
  69. sizer_10 = wx.BoxSizer(wx.HORIZONTAL)
  70. sizer_9 = wx.BoxSizer(wx.HORIZONTAL)
  71. sizer_8 = wx.BoxSizer(wx.HORIZONTAL)
  72. grid_sizer_4 = wx.GridSizer(10, 10, 0, 0)
  73. sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
  74. grid_sizer_3 = wx.GridSizer(2, 2, 0, 0)
  75. sizer_5 = wx.BoxSizer(wx.HORIZONTAL)
  76. grid_sizer_2 = wx.GridSizer(2, 2, 0, 0)
  77. grid_sizer_2.Add(self.extra10, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  78. grid_sizer_2.Add(self.extra101, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  79. grid_sizer_2.Add(self.extra11, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  80. grid_sizer_2.Add(self.extra111, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  81. sizer_4.Add(grid_sizer_2, 1, wx.EXPAND, 0)
  82. sizer_5.Add(self.extra30, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  83. sizer_5.Add(self.extra301, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  84. sizer_4.Add(sizer_5, 1, wx.EXPAND, 0)
  85. grid_sizer_3.Add(self.extra20, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  86. grid_sizer_3.Add(self.extra201, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  87. grid_sizer_3.Add(self.extra21, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  88. grid_sizer_3.Add(self.extra211, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  89. sizer_4.Add(grid_sizer_3, 1, wx.EXPAND, 0)
  90. sizer_3.Add(sizer_4, 1, wx.EXPAND, 0)
  91. sizer_3.Add(grid_sizer_4, 1, wx.EXPAND, 0)
  92. sizer_8.Add(self.info10, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  93. sizer_8.Add(self.info11, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  94. sizer_7.Add(sizer_8, 1, wx.EXPAND, 0)
  95. sizer_9.Add(self.info20, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  96. sizer_9.Add(self.info21, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  97. sizer_7.Add(sizer_9, 1, wx.EXPAND, 0)
  98. sizer_10.Add(self.info30, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  99. sizer_10.Add(self.info31, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  100. sizer_7.Add(sizer_10, 1, wx.EXPAND, 0)
  101. sizer_3.Add(sizer_7, 1, wx.EXPAND, 0)
  102. sizer_6.Add(self.nextturn, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  103. sizer_6.Add(self.buybutton, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  104. sizer_6.Add(self.otherbutton, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  105. sizer_3.Add(sizer_6, 1, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 0)
  106. sizer_2.Add(sizer_3, 1, wx.EXPAND, 0)
  107. self.SetSizer(sizer_2)
  108. sizer_2.Fit(self)
  109. self.Layout()
  110. # end wxGlade
  111.  
  112. def initialize(self):
  113. self.turn = 1
  114. self.places = [0,1,1]
  115. 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]]
  116. self.owns = [[0],[0],[0]]
  117. self.jackpot = 0
  118. self.extra101.WriteText(names[1])
  119. self.extra201.WriteText(names[2])
  120. self.extra111.WriteText(str(money[1]))
  121. self.extra211.WriteText(str(money[2]))
  122. self.turn = 0
  123.  
  124. def next_turn(self, event): # wxGlade: game.<event_handler>
  125. print "Event handler `next_turn' not implemented!"
  126. event.Skip()
  127.  
  128. def buy(self, event): # wxGlade: game.<event_handler>
  129. print "Event handler `buy' not implemented!"
  130. event.Skip()
  131.  
  132. # end of class game
  133.  
  134. class Main(wx.Frame):
  135. def __init__(self, *args, **kwds):
  136. # begin wxGlade: Main.__init__
  137. kwds["style"] = wx.DEFAULT_FRAME_STYLE
  138. wx.Frame.__init__(self, *args, **kwds)
  139.  
  140. # Menu Bar
  141. self.menubar = wx.MenuBar()
  142. wxglade_tmp_menu = wx.Menu()
  143. wxglade_tmp_menu.Append(wx.NewId(), "New", "", wx.ITEM_NORMAL)
  144. wxglade_tmp_menu.Append(wx.NewId(), "open", "", wx.ITEM_NORMAL)
  145. self.menubar.Append(wxglade_tmp_menu, "File")
  146. wxglade_tmp_menu = wx.Menu()
  147. self.menubar.Append(wxglade_tmp_menu, "Help")
  148. self.SetMenuBar(self.menubar)
  149. # Menu Bar end
  150. self.p1name = wx.StaticText(self, -1, "Player 1 Name:", style=wx.ALIGN_CENTRE)
  151. self.p1entry = wx.TextCtrl(self, -1, "")
  152. self.p2name = wx.StaticText(self, -1, "Player 2 Name:", style=wx.ALIGN_CENTRE)
  153. self.p2entry = wx.TextCtrl(self, -1, "")
  154. self.moneystart = wx.StaticText(self, -1, "Money:", style=wx.ALIGN_CENTRE)
  155. self.moneyentry = wx.TextCtrl(self, -1, "")
  156. self.newgamebutton = wx.Button(self, -1, "start new game")
  157. self.newgameinfo = wx.StaticText(self, -1, "Money: the ammount of\n money each player gets\n at the start")
  158.  
  159. self.__set_properties()
  160. self.__do_layout()
  161.  
  162. self.Bind(wx.EVT_MENU, self.new_game, id=-1)
  163. self.Bind(wx.EVT_BUTTON, self.new_game, self.newgamebutton)
  164. # end wxGlade
  165.  
  166. def __set_properties(self):
  167. # begin wxGlade: Main.__set_properties
  168. self.SetTitle("frame_1")
  169. # end wxGlade
  170.  
  171. def __do_layout(self):
  172. # begin wxGlade: Main.__do_layout
  173. sizer_1 = wx.BoxSizer(wx.VERTICAL)
  174. grid_sizer_1 = wx.GridSizer(4, 2, 0, 0)
  175. grid_sizer_1.Add(self.p1name, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  176. grid_sizer_1.Add(self.p1entry, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  177. grid_sizer_1.Add(self.p2name, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  178. grid_sizer_1.Add(self.p2entry, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  179. grid_sizer_1.Add(self.moneystart, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  180. grid_sizer_1.Add(self.moneyentry, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  181. grid_sizer_1.Add(self.newgamebutton, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  182. grid_sizer_1.Add(self.newgameinfo, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0)
  183. sizer_1.Add(grid_sizer_1, 1, wx.EXPAND, 0)
  184. self.SetSizer(sizer_1)
  185. sizer_1.Fit(self)
  186. self.Layout()
  187. # end wxGlade
  188.  
  189. def new_game(self, event): # wxGlade: Main.<event_handler>
  190. global names
  191. global money
  192. names = [0,self.p1entry.GetValue(),self.p2entry.GetValue()]
  193. money = [0,int(self.moneyentry.GetValue()),int(self.moneyentry.GetValue())]
  194. game(self).Show()
  195. Main.Hide(self)
  196. game(self).initialize()
  197.  
  198. # end of class Main
  199.  
  200. if __name__ == "__main__":
  201. app = wx.PySimpleApp(0)
  202. wx.InitAllImageHandlers()
  203. frame_1 = Main(None, -1, "")
  204. app.SetTopWindow(frame_1)
  205. frame_1.Show()
  206. app.MainLoop()
Reputation Points: 25
Solved Threads: 11
Posting Whiz in Training
Kruptein is offline Offline
258 posts
since Sep 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: How can I make a loop that changes?
Next Thread in Python Forum Timeline: Python Question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC