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


Python Gui.mainloop方法代码示例

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


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

示例1: figure8

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import mainloop [as 别名]
def figure8():
    print 'Figure 17.6'

    g = Gui()
    options = dict(side=TOP, fill=X)

    # create the widgets
    g.fr()
    la = g.la(side=TOP, text='List of colors:')
    lb = g.lb(side=LEFT)
    sb = g.sb(side=RIGHT, fill=Y)
    g.endfr()

    bu = g.bu(side=BOTTOM, text='OK', command=g.quit)

    # fill the listbox with color names
    colors = []
    for line in open('/etc/X11/rgb.txt'):
        t = line.split('\t')
        name = t[-1].strip()
        colors.append(name)

    for color in colors:
        lb.insert(END, color)

    # tell the listbox and the scrollbar about each other
    lb.configure(yscrollcommand=sb.set)
    sb.configure(command=lb.yview)

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

示例2: Hwindow

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import mainloop [as 别名]
class Hwindow():
	"""Creates host/join menu."""
	def __init__(self):
		self.h = Gui() # make h window
		self.h.title('Othello!')
		self.h.la(text='Game Name (no spaces)')
		self.entryField = self.h.en()
		self.h.gr(cols=2)
		hostButton = self.h.bu(text='Host Game', command=self.host)
		joinButton = self.h.bu(text='Join Game',command=self.join)
		self.h.mainloop()

	def host(self):
		"""Creates a game w/ 2 players and 2 computers."""
		name = self.entryField.get()
		data = {
				'gameName': name
		}

		req = urllib2.Request('http://othello.herokuapp.com/createGame')
		req.add_header('Content-Type', 'application/json')

		response = urllib2.urlopen(req, json.dumps(data))
		self.h.destroy() # close h window
		os.system('python board_piece_final_tweaked1.py ' + name + ' black')

	def join(self):
		"""Joins an existing game w/ 2 players and 2 computers."""

		name = self.entryField.get()
		self.h.destroy() # close h window
		os.system('python board_piece_final_tweaked1.py ' + name + ' white')
开发者ID:allisongpatterson,项目名称:Othello,代码行数:34,代码来源:startup.py

示例3: figure1

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import mainloop [as 别名]
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,代码行数:11,代码来源:pack_demo.py

示例4: figure4

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import mainloop [as 别名]
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,代码行数:12,代码来源:pack_demo.py

示例5: figure7

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import mainloop [as 别名]
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,代码行数:13,代码来源:pack_demo.py

示例6: figure9

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import mainloop [as 别名]
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,代码行数:13,代码来源:pack_demo.py

示例7: Gwindow

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import mainloop [as 别名]
class Gwindow(): 
	"""Creates local/internet menu."""
	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()

	def local(self):
		"""Creates a game w/ 2 players on 1 computer."""
		self.g.destroy() # close g window
		os.system('python board_piece_final_tweaked.py') # start local game

	def internet(self):
		"""Leads to next menu."""
		self.g.destroy() # close g window
		Hwindow()
开发者ID:allisongpatterson,项目名称:Othello,代码行数:21,代码来源:startup.py

示例8: Gui

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import mainloop [as 别名]
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,代码行数:17,代码来源:19-4.py

示例9: Gui

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import mainloop [as 别名]


win = Gui()	#initialise a win object
win.title('GPA Analysis')
win.row()
logo1=PIL.open('logo.png')
logo=ImageTk.PhotoImage(logo1)
win.la(image=logo)
win.row([0,0], padx=50)
win.la(text='Analysing 4th sem, ECE results \n of the year 2014')
win.col()
win.bu(text='About the app', command=ab_app)
win.bu(text='About the Developer', command=ab_dev)
win.la(text='Kindly mail your feedback to \n [email protected]')
win.endcol()
win.col([0,3],pady=70,padx=50)
win.la(text='Enter your USN')
entry=win.en(text='1BM12EC129')
win.bu(text='View result analysis', command=res)	#function res is invoked when the bu is clicked
win.endcol()
win.row([0,4], padx=1)
win.col()
bms=PIL.open('bmslogo.png')
bms=ImageTk.PhotoImage(bms)
win.la(image=bms)


win.mainloop()

开发者ID:hgsujay,项目名称:SGPA_py,代码行数:30,代码来源:res.py

示例10: ques_pos

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import mainloop [as 别名]
    presuf=sample(list2, 4)[:]
    r=randint(1,2)
    if r==1:
        ques_pos()
    elif r==2:
        ques_neg()
    
def close(event=NONE):
    if tkMessageBox.askyesno("Quit","Do You Want To Quit???"):
        p.destroy()
    

p=Gui()
p.title('Sentiment Analysis')
p.geometry(newGeometry='700x500')

fr=p.fr()
canint=p.ca(bg='green')
imag=Image.open('pic1.jpg')
imag2=ImageTk.PhotoImage(imag)
canint.image([300,-200],image=imag2)
canint.image=imag2
var=IntVar(0)
var2=IntVar(0)
but1=p.bu('YES',command=start,font=('bold',15), bg='red', fg='white', activebackground='white',activeforeground='red',bd=8).place(x=175,y=370, height=50, width=80)
p.bind('y',start)
but2=p.bu('NO',command=close,font=('bold',15), bg='red', fg='white', activebackground='white',activeforeground='red',bd=8).place(x=450,y=370, height=50, width=80)
item1=canint.create_text(350,140,text="\nWelcome!!!\n Hope You Had A Great Day Till Now.\nIf Not, We Are Gonna Make It Great With This Program!!!\n\n\nSo Shall We Begin???",font=('BOOKMAN OLD STYLE',17,'bold'),justify=CENTER,fill='white')
p.bind('n',close)
p.mainloop()
开发者ID:VedantPro,项目名称:Sentiment-Analysis,代码行数:32,代码来源:Project+-+Optimism+Test.py

示例11: launch

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import mainloop [as 别名]
def launch():
    g = Gui()
    g.mainloop()
开发者ID:vpreston,项目名称:MediaShareProject,代码行数:5,代码来源:password_login.py

示例12: main

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import mainloop [as 别名]
def main():
    client = MongoClient()
    db = client.test_database

    users = db.users
    users.remove()
    print users
    users.insert({'user':'hey', 'password':'there'})
    for thing in users.find():
        print thing

    def newusergui():
        def close():
            signupgui.quit()
            
        def newuser():
            for user in users.find():
                for info in user:
                    print info
                    print user[info]
                    if user[info]==newusername.get():
                        print 'already in use'
                        label.config(text="That username is already in use.")
                        return
            if newpassword.get()==repeatnewpassword.get():
                print 'running this loop'
                users.insert({'user':newusername.get(), 'password': newpassword.get()})
                print users
                label.config(text="Thank you for signing up!")
                close()
                launch()
                return True
            else:
                label.config(text="Your passwords don't match! Please try again")
            
        usernamelabel=signupgui.la(text='Username:')
        newusername=signupgui.en()
        newpasswordlabel=signupgui.la(text='Password:')
        newpassword=signupgui.en(show='*')
        repeatpasswordlabel=signupgui.la(text='Re-enter Password')
        repeatnewpassword=signupgui.en(show='*')
        button=signupgui.bu(text="Let's get started!",command=newuser)
        label=signupgui.la()
        

    def logingui():
    
        def close():
            for user in users.find():
                for info in user:
                    if password.get()==user[info]:
                        label.config(text= "You are now logged in!")
                        signupgui.quit()
                        launch()
                        return True 
                    else:
                        label.config(text= "We do not recognize your username or password, please try again.")
                    
        usernamelabel=signupgui.la(text = "MusicSwAPPer Username:  ")
        username = signupgui.en() 
        passwordlabel=signupgui.la("MusicSwAPPer Password:  ")
        password = signupgui.en(show = '*')
        button=signupgui.bu(text="Let's get started!",command=close)
        label=signupgui.la()

            
    signupgui=Gui()
    signupgui.title('MusicSwAPPer Sign Up')
    signuporlogin = signupgui.la(text = 'Please Sign-In or Sign-Up!')
    signupgui.row()
    login = signupgui.bu(text = 'Sign in', command=logingui)
    sign = signupgui.bu(text = 'Sign up', command=newusergui)
    signupgui.endrow()

    signupgui.mainloop()
开发者ID:vpreston,项目名称:MediaShareProject,代码行数:77,代码来源:password_login.py

示例13: main

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import mainloop [as 别名]
def main():
    """
    Launches login system everytime the script is run, users have the option of signing in, or signing up if they have not already established an account and accout information. Upon login/signup, the main application is launched
    """
    
    def newusergui():
        """
        for anyone who needs to register, this adds them to the database system
        """
        def newuser():
            global username
            for user in users.find():
                for info in user:
                    if user[info]==newusername.get():
                        label.config(text="That username is already in use.")
                        return
            if newpassword.get()==repeatnewpassword.get():
                users.insert({'user':newusername.get(), 'password': newpassword.get()})
                db.add_user(newusername.get(), newpassword.get())
                label.config(text="Thank you for signing up!")
                username = newusername.get()
                launch()
            else:
                label.config(text="Your passwords don't match! Please try again")
            
        usernamelabel=g.la(text='Username:')
        newusername=g.en()
        newpasswordlabel=g.la(text='Password:')
        newpassword=g.en(show='*')
        repeatpasswordlabel=g.la(text='Re-enter Password')
        repeatnewpassword=g.en(show='*')
        button=g.bu(text="Let's get started!",command=newuser)
        label=g.la()
        

    def logingui():
        """
        this launches the general sign-in gui for those who have registered
        """
        
        def close():
            global username
            for user in users.find():
                    if password.get()==user['password'] and usernameentry.get() == user['user']:
                        label.config(text= "You are now logged in!")
                        username = usernameentry.get()
                        g.quit()
                        launch()
                        return True 
                    else:
                        label.config(text= "We do not recognize your username or password, please try again.")
                    
        usernamelabel=g.la(text = "MusicSwAPPer Username:  ")
        usernameentry = g.en() 
        passwordlabel=g.la("MusicSwAPPer Password:  ")
        password = g.en(show = '*')
        button=g.bu(text="Let's get started!",command=close)
        label=g.la()
               
    g=Gui()
    g.title('Launch MusicSwAPPer')
    signuporlogin = g.la(text = 'Please Sign-In or Sign-Up!')
    g.row()
    login = g.bu(text = 'Sign in', command=logingui)
    sign = g.bu(text = 'Sign up', command=newusergui)
    g.endrow()

    g.mainloop()
开发者ID:vpreston,项目名称:MediaShareProject,代码行数:70,代码来源:rawmingui.py

示例14: launch

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import mainloop [as 别名]

#.........这里部分代码省略.........
        global username
        for i in shared_source.distinct(username):
            if i['link'] not in shared_viewer.distinct('link'):
                add_link(i)
                link = new_shared_list.canvas.text([0,share_count], text = str(i['link']), activefill = 'blue')
                link.bind('<Double-1>', onObjectClick)
                share_count -= 12

    def onObjectClick(event):
        """
        allows us to double click on a link and show it, as well as remove it from the list of need to view links
        """
        global username
        for thing in point_total.find():
            for key in thing:
                if key == username:
                    existing = thing[username]
                    point_total.update({username: existing}, {'$inc': {username:1}})
                    points.config(text = str(existing + 1))
        index = event.widget.find_closest(event.x, event.y)
        i = shared_viewer.find()
        access = i[index[0] - 1]
        link = access['link']
        url_display(link)
        shared_source.remove({username: {'link':access['link'], 'friend':access['friend']}})


    #General set-up
    pretty = 'light cyan'

    gui = Gui()
    gui.title('MusicswAPPer')


    gui.row()
    gui.la(text = 'Welcome to the swAPP', bg = 'black', fg='cyan', justify = 'left', font = ('Times', 20, 'bold italic'), height = 2, relief = 'groove')
    gui.endrow()
    gui.row(bg=pretty)
    gui.col(bg=pretty)
    gui.bu(text = 'Refresh', fg = 'forest green', font = ('Times', 15, 'bold'), bg=pretty, activeforeground='forest green', activebackground='powder blue', command = update) 
    gui.row([0,1], pady = 10, bg=pretty)
    gui.endrow()
    gui.la(text = 'Share a link', bg = pretty, font = ('Times', 13, 'italic'), anchor = 'left', justify='left')
    friend = gui.en(text = 'Who do you want to share with?', disabledforeground = 'light gray', fg = 'black', font = ('Times', 12))
    en = gui.en(text = 'Insert URL here', font = ('Times', 12))
    gui.bu(text = 'Share', font = ('Times', 15, 'bold'), bg = pretty, fg = 'forest green', activebackground = 'powder blue', activeforeground = 'forest green', command = print_entry)
    label = gui.la(bg=pretty, font=('Times', 11))

    gui.row([0,1], pady = 10, bg=pretty)
    gui.endrow()

    gui.la(text = 'Share history', bg=pretty, font=('Times',13, 'italic'))
    share_history = gui.sc(width = 500, height = 300)
    share_history.canvas.configure(confine = False, scrollregion = (0,0,1000,1000)) 
     
    gui.endcol() 

    gui.col(bg=pretty)
    gui.ca(height = 100, width = 5, bg=pretty, bd=0)
    gui.endcol()
    gui.col(bg=pretty)
    gui.ca(height = 10, width = 5, bg=pretty, bd=0)
    gui.ca(height = 10, width = 5, bg='black',bd=0)
    gui.ca(height = 10, width = 5, bg=pretty,bd=0)
    gui.ca(height = 10, width = 5, bg='black',bd=0)
    gui.ca(height = 10, width = 5, bg=pretty,bd=0)
    gui.ca(height = 10, width = 5, bg='black',bd=0)
    gui.ca(height = 10, width = 5, bg=pretty,bd=0)
    gui.ca(height = 10, width = 5, bg='black',bd=0)
    gui.ca(height = 10, width = 5, bg=pretty,bd=0)
    gui.endcol()
    gui.col(bg=pretty)
    gui.ca(height = 100, width = 5, bg=pretty)
    gui.endcol()

    gui.col(bg=pretty)

    gui.la(text = 'New Shares from Friends', bg = pretty, font=('Times', 13, 'italic'))
    new_shared_list = gui.sc(width = 500, height = 100)
    new_shared_list.canvas.configure(confine = False, scrollregion = (0,0,1000,1000))

    gui.row([0,1], pady = 30, bg=pretty)
    gui.endrow()

    gui.la(text = 'Viewer', bg=pretty, font = ('Times', 13, 'italic'))
    canvas = gui.ca(width = 500, height = 300, bg='black')
    canvas.configure(confine = False, scrollregion = (0,0,2000, 2000))

    points = gui.la(bg=pretty)


    gui.endcol()

    gui.col(bg=pretty)
    gui.ca(height = 100, width = 5, bg=pretty)
    gui.endcol()

    gui.endrow()
    initialize()
    gui.mainloop()
开发者ID:vpreston,项目名称:MediaShareProject,代码行数:104,代码来源:rawmingui.py


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