Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#!/usr/bin/python
import etk
cols = 3
rows = 3
t = etk.Table(cols=cols, rows=rows, homogeneous=etk.Table.HOMOGENEOUS)
def on_clicked(button):
print button.label
return True
pos = 0
for name in ['One', 'Two', 'Three', 'Four', 'Five', 'Six']:
b = etk.Button(label=name)
b.connect("clicked", on_clicked)
row = pos / cols
col = pos % cols
t.attach_default(b, col, col, row, row)
pos += 1
bye = etk.Button(label="Hello World")
bye.connect("clicked", lambda x: etk.main_quit())
#!/usr/bin/python
import etk
cols = 1
rows = 2
helpImage = etk.Image()
helpImage.set_from_stock(etk.c_etk.StockEnums.HELP_BROWSER, etk.c_etk.StockEnums.SMALL)
def giveHelp(menu):
print 'Sorry! :)'
t = etk.Table(cols=cols, rows=rows, homogeneous=etk.Table.NOT_HOMOGENEOUS)
mb = etk.MenuBar()
menuFileButton = etk.MenuItem(label='File')
menuHelpButton = etk.MenuItemImage(label='Help!')
menuHelpButton.image = helpImage #this image won't be displayed in the menubar
menuHelpButton.on_activated(giveHelp) #this event is not triggered
menuSeparator = etk.MenuItemSeparator()
#MenuFile
menuFile = etk.Menu()
menuCheckButton = etk.MenuItem(label='Menu Check buttons')
menuRadioButton = etk.MenuItem(label='Menu Radio buttons')
menuNeedHelpButton = etk.MenuItemImage(label='Help')
menuNeedHelpButton.image = helpImage
##################################
## Create Widget for the first tab
image = etk.Image()
image.set_from_stock (etk.c_etk.StockEnums.APPLICATIONS_DEVELOPMENT, etk.c_etk.StockEnums.BIG)
buttons = [etk.Button(), etk.CheckButton(), etk.CheckButton()]
buttons[0].set_from_stock (etk.c_etk.StockEnums.DOCUMENT_OPEN)
labels = [etk.Label(text="App Name"), etk.Label(text="Generic Info"),
etk.Label(text="Comments"), etk.Label(text="Executable"),
etk.Label(text="Window Name"),etk.Label(text="Window Class"),
etk.Label(text="Startup Notify"),etk.Label(text="Wait Exit")]
entries = [etk.Entry() for i in range(6)]
table = etk.Table(cols=2, rows=10, homogeneous=etk.Table.NOT_HOMOGENEOUS)
table.attach(image, 0, 0, 0, 0, etk.Table.NONE, 0, 0)
table.attach(buttons[0], 1, 1, 0, 0, etk.Table.HEXPAND, 0, 0)
for i in range(6):
table.attach(labels[i], 0, 0, 2 + i, 2 + i, etk.Table.HFILL, 0, 0)
table.attach_default(entries[i], 1, 1, 2 + i, 2 + i)
table.attach(labels[6], 0, 0, 8, 8, etk.Table.HFILL, 0, 0)
table.attach_default(buttons[1], 1, 1, 8, 8)
table.attach(labels[7], 0, 0, 9, 9, etk.Table.HFILL, 0, 0)
table.attach_default(buttons[2], 1, 1, 9, 9)
###################################
## Create Widget for the second tab
align = etk.Alignment(0.5, 0.5, 0.2, 0.0)
labels = [etk.Label(text="App Name"), etk.Label(text="Generic Info"),
etk.Label(text="Comments"), etk.Label(text="Executable"),
etk.Label(text="Window Name"),etk.Label(text="Window Class"),
etk.Label(text="Startup Notify"),etk.Label(text="Wait Exit")]
entries = [etk.Entry() for i in range(6)]
table = etk.Table(cols=2, rows=10, homogeneous=etk.Table.NOT_HOMOGENEOUS)
table.attach(image, 0, 0, 0, 0, etk.Table.NONE, 0, 0)
table.attach(buttons[0], 1, 1, 0, 0, etk.Table.HEXPAND, 0, 0)
for i in range(6):
table.attach(labels[i], 0, 0, 2 + i, 2 + i, etk.Table.HFILL, 0, 0)
table.attach_default(entries[i], 1, 1, 2 + i, 2 + i)
table.attach(labels[6], 0, 0, 8, 8, etk.Table.HFILL, 0, 0)
table.attach_default(buttons[1], 1, 1, 8, 8)
table.attach(labels[7], 0, 0, 9, 9, etk.Table.HFILL, 0, 0)
table.attach_default(buttons[2], 1, 1, 9, 9)
###################################
## Create Widget for the second tab
align = etk.Alignment(0.5, 0.5, 0.2, 0.0)
vbox = etk.VBox(False, 3)
align.add(vbox)
button_normal = etk.Button(label="Normal button")
vbox.append(button_normal, etk.VBox.START, etk.VBox.NONE, 0)
button_toggle = etk.ToggleButton(label="Toggle button")
vbox.append(button_toggle, etk.VBox.START, etk.VBox.NONE, 0)