本文整理汇总了Python中menu.Menu.display方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.display方法的具体用法?Python Menu.display怎么用?Python Menu.display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类menu.Menu
的用法示例。
在下文中一共展示了Menu.display方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import display [as 别名]
def __init__(self, stdscreen, userpass):
self.screen = stdscreen
self.username = userpass['user']
self.password = userpass['pass']
self.database_manager = DatabaseManager(self.screen, userpass)
self.screen_manager = ScreenManager(self.screen)
self.table_manager = TableManager(self.screen, userpass)
self.query_manager = queryDB(self.screen, userpass)
headeroptions = {'user':self.username}
#I ran into an error here when trying to set cursur to invisible
#this if/try makes sure that both the version of curses and the
#terminal support this functionality
if hasattr(curses, 'curs_set'):
try:
curses.curs_set(0)
except:
pass
importer = impexp(self.screen, userpass)
data_items = [
('Import', self.database_manager.display_all_databases_opt, importer.list_sql_files),
('Export', self.database_manager.display_all_databases_opt, importer.export)
]
data = Menu(data_items, self.screen, headeroptions)
browse_database_items = [
('List Databases', self.database_manager.display_all_databases),
('Create', self.database_manager.create_new_database),
('Copy', self.database_manager.display_all_copy_database),
('Drop', self.database_manager.display_all_delete_database)
]
browse_database = Menu(browse_database_items, self.screen, headeroptions)
browse_table_items = [
('List Tables', self.database_manager.display_all_databases_opt, self.table_manager.listTables),
('Create', self.database_manager.display_all_databases_opt, self.table_manager.createTable),
('Delete', self.database_manager.display_all_databases_opt, self.table_manager.list_drop_tables)
]
browse_table = Menu(browse_table_items, self.screen, headeroptions)
query_items = [
('Enter A Query', self.database_manager.display_all_databases_opt, self.query_manager.do),
('Save A Query', self.query_manager.save),
('View Past Queries', self.database_manager.display_all_databases_opt, self.query_manager.get_history),
('View Saved Queries', self.database_manager.display_all_databases_opt, self.query_manager.get_saved)
]
query = Menu(query_items, self.screen, headeroptions)
main_menu_items = [
('Data Management', data.display),
('Browse Databases', browse_database.display),
('Browse Tables', browse_table.display),
('Query',query.display)
]
main_menu = Menu(main_menu_items, self.screen, headeroptions)
main_menu.display()
示例2: display_all_databases_opt
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import display [as 别名]
def display_all_databases_opt(self, action):
parsed_dbs = []
databases = self.fetch_all_databases()
if databases is not None:
for db in databases:
lst = (str(db[0]),action,str(db[0]))
parsed_dbs.append(tuple(lst))
headoptions = {'title':"Select Database",'user':self.username}
displayDatabasesMenu = Menu(parsed_dbs, self.screen, headoptions)
displayDatabasesMenu.display()
示例3: list_drop_tables
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import display [as 别名]
def list_drop_tables(self, dbname):
table_query = "SELECT table_name FROM information_schema.tables where table_schema = 'public'"
rows = query.query(table_query, dbname, self.screen, None, None, self.username, self.password)
parsed_table_menu = []
for datas in rows[1]:
opts = {'db':dbname,'table':str(datas[0])}
lst = (str(datas[0]),self.drop_table, opts)
parsed_table_menu.append(tuple(lst))
headeropts = {'db':dbname,'title':"Select Table to Drop",'user':self.username}
table_menu = Menu(parsed_table_menu,self.screen, headeropts)
table_menu.display()
示例4: display_all_databases
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import display [as 别名]
def display_all_databases(self):
parsed_dbs = []
databases = self.fetch_all_databases()
if databases is not None:
for db in databases:
lst = list(db)
lst.append(curses.flash)
parsed_dbs.append(tuple(lst))
headeroptions = {'title':"List of Databases",'user':self.username}
displayDatabasesMenu = Menu(parsed_dbs, self.screen, headeroptions)
displayDatabasesMenu.display()
示例5: display_all_delete_database
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import display [as 别名]
def display_all_delete_database(self):
parsed_dbs = []
databases = self.fetch_all_databases()
if databases is not None:
for db in databases:
lst = list(db)
lst.append(self.drop_database)
lst.append(db)
parsed_dbs.append(tuple(lst))
headoptions = {'title':"Select Database to delete",'user':self.username}
displayDatabasesMenu = Menu(parsed_dbs, self.screen, headoptions)
displayDatabasesMenu.display()
示例6: list_sql_files
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import display [as 别名]
def list_sql_files(self, dbname):
top = os.getcwd()
dir = os.listdir(top)
parsed_file = []
count = 0
for f in dir:
if fnmatch.fnmatch(f, '*.sql'):
myOpt = {'dbname':dbname,'file':str(f)}
lst = (str(f), self.import_sql, myOpt)
parsed_file.append(tuple(lst))
count = 1
if count == 1:
headeropts = {'db':dbname, 'title':"Select file to import", 'user':self.username}
sqlfiles = Menu(parsed_file, self.screen, headeropts)
sqlfiles.display()
else:
error.throw(self.screen, "No .sql files")
示例7: menu_items
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import display [as 别名]
def menu_items(self, stdscreen):
curses.curs_set(0)
main_menu = Menu(self.list, stdscreen)
main_menu.display()