本文整理汇总了Python中interface.Interface.set_screen方法的典型用法代码示例。如果您正苦于以下问题:Python Interface.set_screen方法的具体用法?Python Interface.set_screen怎么用?Python Interface.set_screen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interface.Interface
的用法示例。
在下文中一共展示了Interface.set_screen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import set_screen [as 别名]
class GithubMobile:
def __init__(self):
self.homedir='E:\\Python\\apps\\simon816\\GithubMobile\\'
self._iface=Interface()
self._config=ConfigMgr(self.homedir)
self._users=UserManager(self.homedir)
self._repoMgr=repoMgr(self._iface)
if self._config.global_user_set:
lb=self._iface.listbox([
(u'Recent Repos',self.recent_repos),
(u'New Repo',self.new_repo),
(u'Open Repo',self.click_open_repo),
(u'Change Global Settings',self.change_settings)
])
else:
lb=self._iface.listbox([(u'Create Account',self.set_account)])
s=self._iface.create_screen(body=lb,title=u'Github Mobile',name='Into screen')
self._iface.set_screen(s)
def set_account(self,data=[u'']*3):
f=self._iface.form([
(u'Display Name','text',data[0]),
(u'Username','text',data[1]),
(u'Email','text',data[2])
],flags=17)
try:data=[i[2] for i in f]
except IndexError:return #not all form was filled in
user={'displayname':data[0],'username':data[1],'email':data[2]}
self._config.set_global_user(user)
name=user['username']
del user['username']
self._users.updateUser(name,**user)
def recent_repos(self):
items=[]
locs=[]
for repoinfo in self._config.recent_repos():
items.append(unicode(repoinfo[0]))
locs.append(repoinfo[1])
if not len(items):return
ind=self._iface.over_list(items)
if ind is not None:
self.open_repo(loc=locs[ind])
def change_settings(self):
user=self._config.global_user()
user=[unicode(user[k]) for k in ['displayname','username','email']]
self.set_account(user)
def click_open_repo(self):
choice=self._iface.over_list([u'Open Local',u'Open Remote'])
if choice==0:
self.open_repo()
elif choice==1:
self._repoMgr.openRemote(self._config.global_user()['username'])
def open_repo(self,loc=None):
if not loc:loc=util.select('dir',self.homedir+'REPOS')
if not loc:return
if self._repoMgr.is_repo(loc):
conf=config()
conf.open(loc+'.git\\config','')
self._config.add_recent(conf.get_key_data('info','name'),loc)
self._repoMgr.openRepo(loc,conf)
conf.close()
else:
self._iface.error('Not a valid repositiory')
def new_repo(self):
name=self._iface.prompt('Name for repository')
dir=util.select('dir',self.homedir)
conf=self._repoMgr.create_repository(dir,name=name)
self._config.add_recent(name,dir)
self._repoMgr.openRepo(dir,conf)