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


Python Gui.sc方法代码示例

本文整理汇总了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:
#.........这里部分代码省略.........
开发者ID:vpreston,项目名称:MediaShareProject,代码行数:103,代码来源:rawmingui.py

示例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)
开发者ID:vpreston,项目名称:MediaShareProject,代码行数:32,代码来源:rawmingui_w_classes.py


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