當前位置: 首頁>>代碼示例>>Python>>正文


Python Gui.bu方法代碼示例

本文整理匯總了Python中swampy.Gui.bu方法的典型用法代碼示例。如果您正苦於以下問題:Python Gui.bu方法的具體用法?Python Gui.bu怎麽用?Python Gui.bu使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在swampy.Gui的用法示例。


在下文中一共展示了Gui.bu方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Hwindow

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [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

示例2: figure1

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [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

示例3: figure4

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [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

示例4: figure7

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [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

示例5: figure9

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [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

示例6: figure8

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [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

示例7: Gwindow

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [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: Vector

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [as 別名]
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")
    item = Vector(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 = Vector(item)


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

g.mainloop()
開發者ID:venkateshwaracholan,項目名稱:Thinkpython,代碼行數:32,代碼來源:nineteen_five_vector.py

示例9: res

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [as 別名]
def res():
            u=entry.get()		#get the entry from the txt field(input USN)
            final_res(u.upper())	#pass the usn into the function



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)

開發者ID:hgsujay,項目名稱:SGPA_py,代碼行數:31,代碼來源:res.py

示例10: callback1

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [as 別名]

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, message:
        # 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)

g.mainloop()
開發者ID:B-Rich,項目名稱:ThinkPython,代碼行數:31,代碼來源:circle_demo.py

示例11: main

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [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

示例12: make_button

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [as 別名]
        if button:
            make_button(n-1)
        if n == 0:
            return button


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


def print_button():
    global count
    count += 1
    print count,"pressed"
    b = g.bu(text='Press me', command=print_button)
    if(count == 3):
        return
    

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


def callback2():
    g.la(text='Nice job.')
def a():
    callback1(10)
g.bu(text='Press me.', command=lambda:callback1(10))
g.mainloop()
開發者ID:venkateshwaracholan,項目名稱:Thinkpython,代碼行數:32,代碼來源:nineteen_one.py

示例13: Gui

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [as 別名]
from swampy.Gui import *

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

def make_button():
	b2 = g.bu(text = 'Press here too..!!!', command = make_label)

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

b1 = g.bu(text = 'Press here', command = make_button)

g.mainloop()
開發者ID:sirajmuneer123,項目名稱:think-python-solutions,代碼行數:16,代碼來源:19-1.py

示例14: Gui

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [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

示例15: drop

# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import bu [as 別名]
        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,代碼行數:32,代碼來源:draggable_demo.py


注:本文中的swampy.Gui.bu方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。