Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # image: http://imgur.com/bJQL9Qb.png
- #
- import wx
- class Example(wx.Frame):
- A = [
- "H", " ", " ", " ", " ", " ", " ", " ", " ",
- " "," "," "," "," "," "," "," ", "He",
- "Li", "Be"," "," "," "," "," "," "," ",
- " "," "," ", "B" , "C", "N", "O", "F" ,
- "Ne", "Na", "Mg"," "," "," "," "," ",
- " "," "," "," "," ", "Al", "Si", "P",
- "S", "Cl", "Ar", "K", "Ca","Sc", "Ti",
- "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu",
- "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr",
- "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc",
- "Ru","Rh", "Pd", "Ag", "Cd", "In", "Sn",
- "Sb", "Te", "I", "Xe", "Cs", "Ba", "" ,
- "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt",
- "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At",
- "Rn", "Fr", "Ra", "", "Rf", "Db", "Sg",
- "Bh", "Hs","Mt", "Ds", "Rg", "Cn", "Nh",
- "Fl", "Mc", "Lv", "Ts", "Og",
- " "," "," "," "," "," "," "," "," "," ",
- " "," "," "," "," "," ", " ", " "," ", " ", " ",
- "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd",
- "Tb", "Dy", "Ho", "Er", "Tm","Yb", "Lu"," ", " ",
- " ","Ac", "Th" , "Pa", "U", "Np", "Pu", "Am",
- "Cm", "Bk","Cf", "Es", "Fm", "Md" , "No", "Lr",
- " "," "," "," "," "," "," "," "," " ,"Go",
- " "," "," "," "," "," "," "," "
- ]
- def __init__(self, parent, title):
- super(Example, self).__init__(parent, title = title,size = (1000,800))
- self.InitUI()
- self.Centre()
- self.Show()
- def OnClick(self, event): #When the button is clicked
- name = event.GetEventObject().myname
- def InitUI(self):
- p = wx.Panel(self)
- gs = wx.GridSizer(11, 18, 5, 1)
- p.SetSizer(gs)
- for txt in self.A:
- print(txt)
- if txt != ' ':
- # you need `p` instead of `self`
- btn = wx.Button(p, 10, txt, (20, 20))
- btn.myname = txt
- self.Bind(wx.EVT_BUTTON, self.OnClick, btn)
- gs.Add(btn, 0, wx.EXPAND) #Buttons are added
- else:
- gs.Add(wx.StaticText(p, label=''), 0, wx.EXPAND)
- app = wx.App()
- Example(None, title = 'Grid demo')
- app.MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement