本文整理匯總了Python中swampy.Gui.mb方法的典型用法代碼示例。如果您正苦於以下問題:Python Gui.mb方法的具體用法?Python Gui.mb怎麽用?Python Gui.mb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類swampy.Gui
的用法示例。
在下文中一共展示了Gui.mb方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: set_color
# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import mb [as 別名]
g.endcol()
# FRAME 2
g.col()
# ca is for canvas
ca = g.ca(width=200, height=200)
item1 = ca.circle([0, 0], 70, "red")
item2 = ca.rectangle([[0, 0], [60, 60]], "blue")
item3 = ca.text([0, 0], "This is a canvas.", "white")
# mb is for menubutton
mb = g.mb(text="Choose a color")
def set_color(color):
ca.itemconfig(item2, fill=color)
# mi is for menuitem
for color in ["red", "green", "blue"]:
# Callable is an object that can be used like a function
g.mi(mb, color, command=Callable(set_color, color))
g.endcol()
示例2: Gui
# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import mb [as 別名]
"""This module contains code from
Think Python by Allen B. Downey
http://thinkpython.com
Copyright 2012 Allen B. Downey
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
"""
from swampy.Gui import *
g = Gui()
g.title('')
g.la('Select a color:')
colors = ['red', 'green', 'blue']
mb = g.mb(text=colors[0])
def set_color(color):
print color
mb.config(text=color)
for color in colors:
g.mi(mb, text=color, command=Callable(set_color, color))
g.mainloop()
示例3: set_color
# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import mb [as 別名]
from swampy.Gui import *
def set_color(color):
mb.config(text=color)
print color
g = Gui()
g.title('Menubutton Demo')
g.la('Select a color:')
colors = ['red', 'green', 'blue']
mb = g.mb(text='color')
for color in colors:
g.mi(mb, text=color, command=Callable(set_color, color))
g.mainloop()