• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python swampy.Gui类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中swampy.Gui的典型用法代码示例。如果您正苦于以下问题:Python Gui类的具体用法?Python Gui怎么用?Python Gui使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Gui类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

	def __init__(self):
		self.g = Gui() # make g window
		self.g.title('Othello!')
		self.g.gr(cols=2)
		localButton = self.g.bu(text='Local Game', command=self.local)
		internetButton = self.g.bu(text='Internet Game', command=self.internet)
		self.g.mainloop()
开发者ID:allisongpatterson,项目名称:Othello,代码行数:7,代码来源:startup.py


示例2: figure9

def figure9():
    print 'Figure 17.7 a'

    g = Gui()
    options = dict(side=LEFT)
    b1 = g.bu(text='OK', command=g.quit, **options)
    b2 = g.bu(text='Cancel', **options)
    b3 = g.bu(text='Help', **options)

    g.geometry('300x150')
    g.mainloop()
开发者ID:ANB2,项目名称:ThinkPython,代码行数:11,代码来源:pack_demo.py


示例3: figure7

def figure7():
    print 'Figure 17.5'

    g = Gui()
    options = dict(side=TOP, fill=X)
    b1 = g.bu(text='OK', command=g.quit, **options)
    b2 = g.bu(text='Cancel Command', **options)
    b3 = g.bu(text='Help', **options)

    g.mainloop()
    g.destroy()
开发者ID:ANB2,项目名称:ThinkPython,代码行数:11,代码来源:pack_demo.py


示例4: figure1

def figure1():
    print 'Figure 17.3 a'

    g = Gui()
    b1 = g.bu(text='OK', command=g.quit)
    b2 = g.bu(text='Cancel')
    b3 = g.bu(text='Help')

    g.mainloop()
开发者ID:ANB2,项目名称:ThinkPython,代码行数:9,代码来源:pack_demo.py


示例5: figure4

def figure4():
    print 'Figure 17.4 a'

    g = Gui()
    options = dict(side=LEFT, padx=10, pady=10)
    b1 = g.bu(text='OK', command=g.quit, **options)
    b2 = g.bu(text='Cancel', **options)
    b3 = g.bu(text='Help', **options)

    g.mainloop()
开发者ID:ANB2,项目名称:ThinkPython,代码行数:10,代码来源:pack_demo.py


示例6: drop

        # see how far we have moved
        # dx = event.x - self.dragx
        # dy = event.y - self.dragy

        pos = ca.canvas_coords([[self.dragx, self.dragy], [event.x, event.y]])
        print pos
        item = ca.rectangle(pos, fill="red")
        # move the item
        # self.move(dx, dy)

    def drop(self, event):
        """Drops this item."""
        self.config(fill=self.fill)


g = Gui()
ca = g.ca(width=500, height=500, bg="white")

item = ca.rectangle([[-250, -250], [100, 100]], fill="red")

vec = Vector(item)
ca.bind("<ButtonPress-1>", vec.select)


def make_circle(event):
    """Makes a circle item at the location of a button press."""
    dx = event.x
    dy = event.y
    pos = ca.canvas_coords([[event.x, event.y], [event.x + 10, event.y + 10]])
    print pos
    item = ca.rectangle(pos, fill="red")
开发者ID:venkateshwaracholan,项目名称:Thinkpython,代码行数:31,代码来源:nineteen_five_vector.py


示例7: final_res

def final_res(ipusn):
            view=Gui()
            view.title('view results')
            fin=open('RES.txt')

            usn_gpa={}	#an dictionary with usn as key and gpa as items
            name_usn={}
            gpa_usn={}	#an dictionary with gpa as key and usn as items
            linesplit=[]	#an empty list
            gpaacc=[]		#a list to store all the gpas
            usnacc=[]		#a list to store all the usn
            usn_name={}		#a dictionary to map usn to names
            for line in fin:
                        linesplit=line.split(' ')	#reads the line and splits it into list of strings
                        gpa=gpa_calc(linesplit)		#sends the whole list to the function
                        usn_gpa[linesplit[1]]=gpa	#stores the gpa in a dictionary database
                        usnacc.append(linesplit[1])	#stores the usn into a usn accumilator
                        dell=' '
                        usn_name[linesplit[1]]=dell.join(linesplit[2:-18])	#extracts the name from the line
                        if gpa in gpa_usn:			#store all the usns with same GPAs under the GPA key
                                    gpa_usn[gpa].append(linesplit[1])
                        else:
                                    gpa_usn[gpa]=[linesplit[1]]

                        if gpa not in gpaacc:		#store gpa into gpaacc if it is not in the list
                                    gpaacc.append(gpa)

            gpaacc.sort(reverse=True)		#sort the gpa acc for finding the rank

            if ipusn not in usnacc:
                        view.la(text='Invalid USN\n Make sure you have entered the USN correctly')

            gpa2=usn_gpa[ipusn]		#get the gpa of the student whose usn is taken as input
            for i in range(len(gpaacc)):	#find the rank
                           if gpaacc[i]==gpa2:
                                       rank=i+1
            view.row()
            view.col()
            view.la(text='Hello %s' %usn_name[ipusn])
            view.la(text='Your SGPA is %s' %gpa2)
            view.la(text='Your SGPA position is %i: ' %rank)
            view.endcol()
            gpa_usn[gpa2].remove(ipusn)
            view.col(padx=50)
            view.la(text='Your SGPA is tied with %s students' %len(gpa_usn[gpa2]))
            view.col(pady=50)
            view.col(padx=5)
            for u in gpa_usn[gpa2]:
                        var='%s  (%s)' %(usn_name[u], u)
                        view.la(text=var)
                        view.col(pady=5)
开发者ID:hgsujay,项目名称:SGPA_py,代码行数:51,代码来源:res.py


示例8: ab_app

def ab_app():
            abapp=Gui()
            abapp.row([0,1])
            abapp.la(text='This is an app developed to analyse the results of \n BMS College of Engineering, Grading system ')
开发者ID:hgsujay,项目名称:SGPA_py,代码行数:4,代码来源:res.py


示例9: make_label

from swampy.Gui import *

def make_label():
    g.la(text='Thank you.')

g = Gui()
g.title('Gui')

button = g.bu(text='Press me.')
button2 = g.bu(text='No, press me!', command=make_label)
label = g.la(text='Press the buttom.')
canvas = g.ca(width=500, height=500)
canvas.config(bg='white')
item = canvas.circle([0,0], 100, fill='red')
item.config(fill='yellow', outline='orange', width=10)
canvas.rectangle([[0,0], [200,200]],
                 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)
entry = g.en(text='Default text.')
text = g.te(width=100, height=5)
text.insert(END, 'A line of text.')
text.insert(1.1, 'nother')
text.delete(1.2, END)

g.mainloop()
开发者ID:tangc1986,项目名称:PythonStudy,代码行数:28,代码来源:practise19.py


示例10: ab_dev

def ab_dev():
            abdev=Gui()
            abdev.la(text='An app by Sujay HG')
开发者ID:hgsujay,项目名称:SGPA_py,代码行数:3,代码来源:res.py


示例11: Gui

from swampy.Gui import *
import Tkinter
import Image as PIL
import ImageTk

g = Gui()
g.title('Image Viewer')
canvas = g.ca(width = 400, height = 400)
photo = Tkinter.PhotoImage(file = 'danger.gif')
''' PhotoImage reads a file and returns a PhotoImage object that
Tkinter can display '''
canvas.image([0,0], image = photo)
g.la(image = photo)
g.bu(image = photo)
g.mainloop()
开发者ID:sirajmuneer123,项目名称:think-python-solutions,代码行数:15,代码来源:19-4.py


示例12: drop

        dy = event.y - self.dragy

        # save the current drag coordinates
        self.dragx = event.x
        self.dragy = event.y

        # move the item 
        self.move(dx, dy)

    def drop(self, event):
        """Drops this item."""
        self.config(fill=self.fill)


# create the Gui and the Canvas
g = Gui()
ca = g.ca(width=500, height=500, bg='white')

def make_circle(event):
    """Makes a circle item at the location of a button press."""
    pos = ca.canvas_coords([event.x, event.y])
    item = ca.circle(pos, 5, fill='red')
    item = Draggable(item)

ca.bind('<ButtonPress-3>', make_circle)

def make_text(event=None):
    """Pressing Return in the Entry makes a text item."""
    text = en.get()
    item = ca.text([0,0], text)
    item = Draggable(item)
开发者ID:ANB2,项目名称:ThinkPython,代码行数:31,代码来源:draggable_demo.py


示例13: Gui

from swampy.Gui import *
g = Gui()
g.title("Gui")


text = g.te(width=100, height=5)
canvas = g.ca(width=300, height=300)
canvas.config(bg='grey')
circle = None
def change_color():
    global circle
    color = entry.get()
    print color
    if circle == None:
        return
    circle.config(fill=color)

def draw_circle():
    global circle
    circle = canvas.circle([0, 0], 100, fill='red')

g.bu(text='create circle', command=draw_circle)
entry = g.en()
g.bu(text='change color', command=change_color)



g.mainloop()
开发者ID:venkateshwaracholan,项目名称:Thinkpython,代码行数:28,代码来源:nineteen_three.py


示例14: Gui

License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html

This program requires Gui.py, which is part of
Swampy; you can download it from thinkpython.com/swampy.

This program demonstrates how to use the Gui module
to create and operate on Tkinter widgets.

The documentation for the widgets is at
http://www.pythonware.com/library/tkinter/introduction/
"""

from swampy.Gui import *

# create the Gui: the debug flag makes the frames visible
g = Gui(debug=False)

# the topmost structure is a row of widgets
g.row()

# FRAME 1

# the first frame is a column of widgets
g.col()

# la is for label
la1 = g.la(text="This is a label.")

# en is for entry
en = g.en()
en.insert(END, "This is an entry widget.")
开发者ID:Ehsan1981,项目名称:ThinkPython,代码行数:31,代码来源:widget_demo.py


示例15: make_circle

#!/usr/bin/env python

from swampy.Gui import *

def make_circle():
    circle = canvas.circle([0,0], 100, fill='red')
    entry = g.en(text='Enter Color')
    button2 = g.bu(text='Enter', command=change_color)
    global circle, entry

# handle the exception of changing color on a circle not created by 
# the order of operations, i.e. does not get to the color change until circle is created. 
def change_color():
    color = entry.get()
    colorList = ['white', 'black', 'red', 'green', 'blue', 'cyan', 'yellow', 'magenta']
    if color not in colorList:
        print "The color you specified is not valid. Available colors are: "
        for i in colorList:
            print i
    else:
        circle.config(fill=color)

g = Gui()
g.title('Gui')
canvas = g.ca(width=500, height=500)
canvas.config(bg='white')
button1 = g.bu(text="Make Circle", command=make_circle)
g.mainloop()


开发者ID:ericchou-python,项目名称:programming-python,代码行数:28,代码来源:ex19_3.py


示例16: Gui

from swampy.Gui import *

g = Gui()
g.title('')

def callback1():
    g.bu(text='Now press me.', command=callback2)

def callback2():
    g.la(text='Nice job.')

g.bu(text='Press me.', command=callback1)

g.mainloop()
开发者ID:amadjarov,项目名称:thinkPython,代码行数:14,代码来源:ex19_1.py


示例17: Gui

"""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()
开发者ID:ANB2,项目名称:ThinkPython,代码行数:25,代码来源:menubutton_demo.py


示例18: drop

        self.dragy = event.y

        self.move(dx, dy)

    def drop(self, event):
        self.config(fill=self.fill)


def make_circle(event):
    pos = ca.canvas_coords([event.x, event.y])
    item = ca.circle(pos, 5, fill='white')
    Draggable(item)

def make_text(event=None):
    text = en.get()
    item = ca.text([0,0], text)
    Draggable(item)


g = Gui()
g.title('Draggable Demo')
ca = g.ca(width=500, height=500, bg='black')
ca.bind('<ButtonPress-3>', make_circle)

g.row([1,0])
en = g.en()
bu = g.bu('Make text item:', make_text)
en.bind('<Return>', make_text)

g.mainloop()
开发者ID:hacpai,项目名称:reading-lists,代码行数:30,代码来源:draggable_demo.py


示例19: Gui

"""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('')

def callback1():
    g.bu(text='Now press me.', command=callback2)

    def callback2():
        g.la(text='Nice job.')
        g.bu(text='Press me.', command=callback1)
        g.mainloop()
开发者ID:bemagee,项目名称:LearnPython,代码行数:21,代码来源:button_demo.py


示例20: Gui

from swampy.Gui import *

g = Gui()
g.title('19-3.py')
canvas = g.ca(width = 500, height = 600, bg = 'white')
circle = None

def make_circle():
	circle = canvas.circle([0,0], 100)
def make_change():
	if circle == None:
		return
	color = entry.get()
	try:
		circle.config(fill = color)
	except TclError, message:
		print message


b1 = g.bu(text = 'Create Circle', command = make_circle)
entry = g.en()
b2 = g.bu(text = 'Press to Config', command= make_change)

g.mainloop()
开发者ID:sirajmuneer123,项目名称:think-python-solutions,代码行数:24,代码来源:19-3.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python diag.progress函数代码示例发布时间:2022-05-27
下一篇:
Python swampdragon_server.run_server函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap