本文整理汇总了Python中Gui.ca方法的典型用法代码示例。如果您正苦于以下问题:Python Gui.ca方法的具体用法?Python Gui.ca怎么用?Python Gui.ca使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gui
的用法示例。
在下文中一共展示了Gui.ca方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: grapherCalc
# 需要导入模块: import Gui [as 别名]
# 或者: from Gui import ca [as 别名]
def grapherCalc(): #Build the Graph Window
global entry
global grapher
global canvas
try:
grapher.destroy()
except:
error = True #print "DEBUG - NO GRAPHER ENABLED"
grapher = Gui()
grapher.minsize(500,550)
grapher.maxsize(500,550)
grapher.iconbitmap('icon.ico')
grapher.title("WinCalc (Equation Grapher)")
grapher.bind ('<Return>', graphIt)
grapher.gr(cols=3)
grapher.la(text="f(x)=")
entry = grapher.te(width=30,height=1,font=("Courier New", 16))
entry.insert(0.0,"x**2")
grapher.bu("Graph It",command=graphIt)
grapher.endgr()
canvas = grapher.ca(width=500, height=500, bg='white')
graphIt()
tkMessageBox.showinfo(title="WinCalc Equation Grapher - Instructions", message="The equation grapher uses the same syntax as the advanced calculator.\nSyntax errors will result in a blank graph. Radian mode only.")
entry.focus_set()
grapher.mainloop()
示例2: Gui
# 需要导入模块: import Gui [as 别名]
# 或者: from Gui import ca [as 别名]
from Gui import *
g = Gui()
g.title('circle demo')
canvas = g.ca(width=500, height=500, bg='white')
circle = None
def callback1():
"""called when the user presses 'create circle' """
global circle
circle = canvas.circle([0,0], 100)
def callback2():
"""called when the user presses 'Change color' """
# if the circle hasn't been created yet, do nothing
if circle == None:
return
# get the text from the entry and try to change the circle's color
color = entry.get()
try:
circle.config(fill=color)
except TclError:
# probably an unknown color name
print(message)
# create the widgets
g.bu(text='Create circle', command=callback1)
entry = g.en()
g.bu(text='Change color', command=callback2)
示例3: Gui
# 需要导入模块: import Gui [as 别名]
# 或者: from Gui import ca [as 别名]
from Gui import *
g = Gui()
g.title('Blue Rectangle')
canvas = g.ca(width=500, height=500)
canvas.rectangle([[0, 0], [200, 100]], fill='blue', outline='orange', width=10)
canvas.oval([[0, 0], [200, 100]], outline='orange', width=10)
canvas.line([[0, 100], [100, 200], [200, 100]], width=10)
canvas.polygon([[0, 100], [100, 200], [200, 100]],
fill='red', outline='orange', width=10)
g.mainloop()
示例4: create_circle
# 需要导入模块: import Gui [as 别名]
# 或者: from Gui import ca [as 别名]
def create_circle():
global item
item = c.circle([0,0],100,fill='red')
def change_color():
try:
if 'item' in globals():
item.config(fill=entry.get())
else:
g.la(text='First create a circle!!!')
return
except :
g.la(text='Invalid color')
from Gui import *
g = Gui()
b1 = g.bu(text='Press to create a circle',command=create_circle)
c = g.ca(width=500,height=500)
entry=g.en(text='enter the color')
b2 = g.bu(text='Press to change color of circle',command=change_color)
g.mainloop()
示例5: Gui
# 需要导入模块: import Gui [as 别名]
# 或者: from Gui import ca [as 别名]
g.destroy()
g = Gui() # Make a main "g" window
g.title ("Black Jack") # Title the window
g.row([1,1,1,25])
mb_file = g.mb (text = "File", borderwidth = 0, bg = 'black', fg = 'red') # Create a File drop menu
g.mi (mb_file, text = "Return to Arcade", command = kill)
mb_help = g.mb (text = "Help", borderwidth = 0, bg = 'black', fg = 'yellow') # Create a Help drop menu
g.mi (mb_help, text = "Instructions", command = instructions) #call the instruction function
g.la ("", bg = 'black')
g.endrow()
canvas = g.ca (width = 600, height = 550, bg = "darkgreen") # Create a canvas and draw the background of the main game
g.row ([1, 1])
hit = g.bu (text = "Hit Me!", border = 5, command = hit, state = DISABLED) # Put a Hit Me button
stay = g.bu (text = "Stay!", border = 5, command = stay, state = DISABLED) # Put a Stay button
replay = g.bu (text = "Play Again!", border = 5, command = play_again, state = DISABLED) # Put a Play Again button
g.endrow()
g.row ([1,25])
bet = g.bu (text = "Place Bet!", border = 5, command = place_bet) # Put in a place bet button
text = g.te (height = 1, width = 25, fg = 'darkgreen') # Create a text box to type the bet in
text.bind ('<Return>', place_bet) # Bind the enter key with the place bet function
g.endrow()
howto = g.la ('Enter the amount you wish to bet and click "Place Bet!".', bg = 'black', fg = 'yellow') # Make a label at the bottom to instruct the user on how to play
示例6: Gui
# 需要导入模块: import Gui [as 别名]
# 或者: from Gui import ca [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 Gui import *
from Tkinter import PhotoImage
g = Gui()
photo = PhotoImage(file='danger.gif')
g.bu(image=photo)
canvas = g.ca(width=300)
canvas.image([0,0], image=photo)
import Image as PIL
import ImageTk
image = PIL.open('allen.png')
photo2 = ImageTk.PhotoImage(image)
g.la(image=photo2)
g.mainloop()