python - Populate wx.StaticText controls with dictionary key:value pairs -


i have wxpython gui application contains 13 pairs of statictext controls able set labels problematically.

in terms of regression analysis, each pair of statictext controls represents independent variable , coefficient. these key:value pairs stored in python dictionary, allowing me use dictionary comprehension of work.

right now, struggling display contents of python dictionary inside of gui. thoughts?

i happy concatenating key:value pair inside 1 statictext control label, think less messy.

i'm sure there lots of different ways this. use listctrl or better yet, objectlistview. went ahead , created example using statictext controls:

import wx  ######################################################################## class mypanel(wx.panel):     """"""      #----------------------------------------------------------------------     def __init__(self, parent):         """constructor"""         wx.panel.__init__(self, parent)          self.mainsizer = wx.boxsizer(wx.vertical)         self.createcontrols()         self.setsizer(self.mainsizer)      #----------------------------------------------------------------------     def createcontrols(self):         """"""         mydict = {"var1":"co-eff1", "var2":"co-eff2",                   "var3":"co-eff3", "var4":"co-eff4",                   "var5":"co-eff5", "var6":"co-eff6",                   "var7":"co-eff7", "var8":"co-eff8",                   "var9":"co-eff9", "var10":"co-eff10",                   "var11":"co-eff11", "var12":"co-eff12",                   "var13":"co-eff13"}         key in mydict:             lblone = wx.statictext(self, label=key)             lbltwo = wx.statictext(self, label=mydict[key])              sizer = wx.boxsizer(wx.horizontal)             sizer.add(lblone, 0, wx.all, 5)             sizer.add(lbltwo, 0, wx.all, 5)             self.mainsizer.add(sizer)  ######################################################################## class myframe(wx.frame):     """"""      #----------------------------------------------------------------------     def __init__(self):         """constructor"""         wx.frame.__init__(self, none, title="frame example",                           size=(400,400))         panel = mypanel(self)         self.show()  if __name__ == "__main__":     app = wx.app(false)     frame = myframe()     app.mainloop() 

if want see listctrl looks like, go , download wxpython demo package , listctrl demo. objectlistview, can read tutorial.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -