本文整理汇总了Python中swampy.Gui.title方法的典型用法代码示例。如果您正苦于以下问题:Python Gui.title方法的具体用法?Python Gui.title怎么用?Python Gui.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类swampy.Gui
的用法示例。
在下文中一共展示了Gui.title方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Hwindow
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [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')
示例2: final_res
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [as 别名]
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)
示例3: Gwindow
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [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()
示例4: drop
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [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()
示例5: set_color
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [as 别名]
from swampy.Gui import *
def set_color(color):
mb.config(text=color)
print color
g = Gui()
g.title('Menubutton Demo')
g.la('Select a color:')
colors = ['red', 'green', 'blue']
mb = g.mb(text='color')
for color in colors:
g.mi(mb, text=color, command=Callable(set_color, color))
g.mainloop()
示例6: Gui
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [as 别名]
'''import urllib
conn = urllib.urlopen('http://thinkpython.com/secret.html')
for line in conn:
print line.strip()'''
from swampy.Gui import *
g = Gui()
g.title('Web Browser')
canvas = g.ca(width = 400, height = 400)
b1 = g.bu(text = "Click to browse", command = make_change)
示例7: Gui
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [as 别名]
"""Exercise 2
Write a program that creates a Canvas and a Button. When the user presses the Button,
it should draw a circle on the canvas."""
from swampy.Gui import *
g = Gui()
g.title = "Gui"
def make_circle():
canvas.circle([0, 0], 55, fill="orange", outline="white", width=3)
canvas = g.ca(500, 500, bg="black")
g.bu(text="make me a circle", command=make_circle)
g.mainloop()
示例8: testBit
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [as 别名]
#! /usr/bin/python
from swampy.Gui import *
def testBit(int_type, offset):
mask = 1 << offset
return(int_type & mask)
def toggleBit(int_type, offset):
mask = 1 << offset
return(int_type ^ mask)
model = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
g = Gui()
g.title('Font creator')
canvas = g.ca(200, 300, bg='orange')
def redrawCanvas():
canvas.clear()
for line in range(0, 16):
canvas.text([70, 140-18*line], '['+str(line)+']='+str(model[line]))
for pos in range(0, 8):
x = 40 - pos * 10
y = 80 - line * 10
item = canvas.rectangle([[x, y], [x+10, y+10]], fill='white', outline='black', width=1)
if testBit(model[line], pos) > 0:
item.config(fill='black')
def mouseClicked(event):
cc = canvas.canvas_coords([event.x, event.y])
示例9: change_color
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [as 别名]
circle = canvas.circle([0,0], 100, fill='white')
def change_color():
if circle == None:
return 'Create a circle before press button.'
color = entry.get()
try:
circle.config(fill=color)
except:
message = 'probaly an unknown color name'
print message
g = Gui()
g.title('Gui')
button = g.bu(text='Press it', command=callback1)
canvas = g.ca(width=500, height=500)
circle = None
#canvas.config(bg='black')
#item = canvas.rectangle([[0, 0], [200, 200]],
#fill='white', outline='orange',width=10)
#item = canvas.oval([[0, 0], [200, 100]],
#fill='white', outline='orange',width=10)
#item = canvas.line([[0, 100], [100, 200], [200, 100]], width=10, fill='white')
#item = canvas.polygon([[0, 100], [100, 200], [200, 100]], width=10, fill='white', outline='orange')
#entry = g.en(text='Default text.')
#print entry.get()
#text = g.te(width=100, height=5)
#text.insert(2.3, 'nother')
示例10: launch
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [as 别名]
#.........这里部分代码省略.........
"""
global share_count
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)
示例11: Gui
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [as 别名]
from swampy.Gui import *
g = Gui()
g.title('19-2.py')
def make_create():
item = canvas.circle([0,0], 100, fill = 'green')
def make_change():
i = item.config(fill = 'red', outline = 'orange', width = 10)
canvas = g.ca(width = 500, height = 600)
b1 = g.bu(text = 'Press Button', command = make_create)
b2 = g.bu(text = 'Press To change', comman = make_change)
g.mainloop()
示例12: str
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [as 别名]
allows us to double click on a link and show it, as well as remove it from the list of need to view links
"""
for thing in point_total.find():
existing = thing['points']
point_total.update({'points': existing}, {'$set': {'points':existing+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_viewer.remove(access)
shared_source.remove(access)
#General set-up
g.title('Minumum Deliverable URLSender')
g.row()
g.col()
g.la(text = 'Welcome to musicswAPPer')
g.bu(text = 'Update Data', command = MediaShare.update())
g.row([0,1], pady = 10)
g.endrow()
g.la(text = 'Share a link!')
friend = g.en(text = 'Who do you want to share with?')
en = g.en(text = 'Insert URL here')
g.bu(text = 'Share', command = MediaShare.print_entry())
label = g.la()
示例13: Gui
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [as 别名]
from swampy.Gui import *
g = Gui()
g.title('Event')
def make_circle(event):
pos = canvas.canvas_coords([event.x, event.y])
item = canvas.circle(pos, 5, fill = 'red')
canvas = g.ca(width = 400, height = 400, bg = 'white')
canvas.bind('<ButtonPress-1>', make_circle)
g.mainloop()
示例14: Gui
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [as 别名]
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()
示例15: main
# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import title [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()