本文整理匯總了Python中swampy.Gui.sc方法的典型用法代碼示例。如果您正苦於以下問題:Python Gui.sc方法的具體用法?Python Gui.sc怎麽用?Python Gui.sc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類swampy.Gui
的用法示例。
在下文中一共展示了Gui.sc方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: launch
# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import sc [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:
#.........這裏部分代碼省略.........
示例2:
# 需要導入模塊: from swampy import Gui [as 別名]
# 或者: from swampy.Gui import sc [as 別名]
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)
g.endcol()
g.col()
g.la(text = 'New Shares from Friends')
new_shared_list = g.sc(width = 500, height = 100)
new_shared_list.canvas.configure(confine = False, scrollregion = (0,0,1000,1000))
g.row([0,1], pady = 30)