当前位置: 首页>>代码示例>>Python>>正文


Python Gui.ca方法代码示例

本文整理汇总了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()
开发者ID:interwho,项目名称:WinCalc,代码行数:27,代码来源:main.py

示例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)
开发者ID:ErikRHanson,项目名称:think_python,代码行数:33,代码来源:ex03_circle2.py

示例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()
开发者ID:ErikRHanson,项目名称:think_python,代码行数:20,代码来源:sec04_coordinate_sequencs.py

示例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()
开发者ID:binoytv9,项目名称:Think-Python-by-Allen-B-Downey--Exercises,代码行数:31,代码来源:3.py

示例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
开发者ID:Couragyn,项目名称:BlackJack,代码行数:33,代码来源:Working+Blackjack.py

示例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()
开发者ID:ErikRHanson,项目名称:think_python,代码行数:29,代码来源:image_demo.py


注:本文中的Gui.ca方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。