本文整理匯總了Python中swampy.Gui.en方法的典型用法代碼示例。如果您正苦於以下問題:Python Gui.en方法的具體用法?Python Gui.en怎麽用?Python Gui.en使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類swampy.Gui
的用法示例。
在下文中一共展示了Gui.en方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Hwindow
# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import en [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: Gui
# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import en [as 別名]
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()
示例3: Vector
# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import en [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()
示例4: Gui
# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import en [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()
示例5: Gui
# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import en [as 別名]
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')
#text.delete(0.2, END)
#print text.get(0.0, END)
entry = g.en(text='Type a color')
button_color = g.bu(text='Change color', command=change_color)
g.mainloop()
示例6: make_label
# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import en [as 別名]
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()
示例7: Gui
# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import en [as 別名]
g = Gui()
g.title = "Gui"
circle1 = False
def make_circle():
global circle1
circle1 = canvas.circle([random.randint(-200, 200), random.randint(-200, 200)], 55, fill="orange", outline="white", width=3)
def change_circle_color():
if circle1 == False:
g.la(text="You must make the circle first")
return
try:
color = entry.get()
circle1.config(fill=str(color))
except:
g.la(text="Please enter a valid color")
return
canvas = g.ca(500, 500, bg="black")
g.bu(text="make me a circle", command=make_circle)
entry = g.en(text="name a color")
g.bu(text="change circle color to entry", command=change_circle_color)
g.mainloop()
示例8: launch
# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import en [as 別名]
def launch():
"""
launches the 'real' gui system, the one we interact with
"""
#names new databases that we will use now that the application is launched
share_hist = db.share_hist
display = db.display
point_total = db.point_total
shared_source = db.shared_source
shared_viewer = db.shared_viewer
#clears the databases upon running script
#IMPORTANT: leave the shared_viewer.remove()
shared_viewer.remove()
def initialize():
"""
upon running the script, gets data from the database and updates the gui displays
"""
global count
global share_count
global username
try:
for thing in point_total.distinct(username):
amount = thing
points.config(text = str(amount))
except:
point_total.insert({username:10})
for thing in point_total.distinct(username):
amount = thing
points.config(text = str(amount))
for thing in display.distinct(username):
share_history.canvas.text([0,count], text = thing['friend'] + ' ' + thing['share'] + ' ' + str(thing['date']))
count -= 12
for thing in shared_viewer.distinct(username):
link = new_shared_list.canvas.text([0,share_count], text = str(thing[username]['link']), activefill = 'blue')
link.bind('<Double-1>', onObjectClick)
share_count -= 12
def update():
"""
when the update button is pushed, this looks at the database, and will print things not already in the display, as well as log displayed data (meaning that if the gui closes before update is pressed, the data is still saved, and will be displayed the next time update will be pressed)
"""
global count
global username
for log in share_hist.find():
if log not in display.find():
display.insert(log)
share_history.canvas.text([0,count], text = log[username]['friend'] + ' ' + log[username]['share'] + ' ' + str(log[username]['date']))
count -= 12
get_new_shares()
def print_entry():
"""
Allows shares to be made, will check to make sure nothing is a repeat, will log the data. Interactive with the user.
"""
global count
global username
res = []
text = en.get()
connection = friend.get()
for user in users.find():
res.append(user['user'])
if connection not in res:
label.config(text = 'Sorry, user not in our records')
return
follower = ' was shared with '
message = text + follower + connection + '!'
for thing in point_total.distinct(username):
existing = thing
point_total.update({username: existing}, {'$inc': {username:(-1)}})
points.config(text = str(existing-1))
if count == 1:
t = datetime.datetime.now()
if t.minute < 10:
minute = '0'+str(t.minute)
else:
minute = str(t.minute)
timestamp = str(t.month) + '/' + str(t.day) +'/' + str(t.year) + ',' +str(t.hour) + ':' + minute
share_hist.insert({username:{'friend':connection,'share':text, 'date': timestamp}})
shared_source.insert({connection:{'link': text, 'friend':username}})
label.config(text = message)
count -= 12
else:
instance_count = 0
for instance in share_hist.distinct(username):
if text == instance['share'] and connection == instance['friend']:
label.config(text = 'That is a repeat!')
return
instance_count += 1
if instance_count == len(share_hist.distinct(username)):
t = datetime.datetime.now()
if t.minute < 10:
minute = '0'+str(t.minute)
else:
#.........這裏部分代碼省略.........
示例9:
# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import en [as 別名]
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()
g.row([0,1], pady = 10)
g.endrow()
g.la(text = 'Share History')
share_history = g.sc(width = 500, height = 300)
share_history.canvas.configure(confine = False, scrollregion = (0,0,1000,1000))
g.endcol()
g.col()
g.ca(height = 100, width = 50)