本文整理汇总了Python中UI类的典型用法代码示例。如果您正苦于以下问题:Python UI类的具体用法?Python UI怎么用?Python UI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doBuyWeapon
def doBuyWeapon(self, Player):
ShopWaresMenu = UI.MenuClass()
ShopWaresMenu.Title = "Weapons"
# Do bying menu
while not ShopWaresMenu.Returned:
# Fill with with items & information and trade-in value
ShopWaresMenu.clear()
for ShopItem in self.WeaponList:
Name = ShopItem.descString()
ShopWaresMenu.addItem(Name)
ShopWaresMenu.CustomText = (
"You have " + str(Player.Gold) + " gp\nYour weapon: " + Player.Equipment["Weapon"].Base.descString()
)
Index = ShopWaresMenu.doMenu()
if ShopWaresMenu.Returned:
break
ShopItem = self.WeaponList[Index]
if Player.Gold < ShopItem.Value:
print("You cannot afford that!")
UI.waitForKey()
continue
# Secure the transaction
self.WeaponList.remove(ShopItem)
Player.addItem(ShopItem)
Player.Gold -= ShopItem.Value
print(ShopItem.Name, "bought")
UI.waitForKey()
示例2: remove_game
def remove_game(_=None):
"""Remove the currently-chosen game from the game list."""
global selected_game
lastgame_mess = (
"\n (BEE2 will quit, this is the last game set!)"
if len(all_games) == 1 else
""
)
confirm = messagebox.askyesno(
title="BEE2",
message='Are you sure you want to delete "'
+ selected_game.name
+ '"?'
+ lastgame_mess,
)
if confirm:
selected_game.edit_gameinfo(add_line=False)
all_games.remove(selected_game)
config.remove_section(selected_game.name)
config.save()
if not all_games:
UI.quit_application() # If we have no games, nothing can be done
selected_game = all_games[0]
selectedGame_radio.set(0)
add_menu_opts(game_menu)
示例3: main
def main():
my_persons = PersonRepository()
my_activities = ActivityRepository()
my_Controller = Controller(my_persons, my_activities)
my_UI = UI(my_Controller)
my_UI.do_menu()
示例4: main
def main():
# The topLevelObjects is a list to store objects at the top level to listen for events.
# A typical use should only have the navigationViewController inside it as the subclasses manage events
global topLevelObjects # Allow for the topLevelObjects list to be used elsewhere
topLevelObjects = []
# Initialise screen and pyGame
pygame.init()
screen = pygame.display.set_mode((800, 600))
# Set the window title
pygame.display.set_caption('Squares')
# initialisation of the navigation controller.
navigationViewController = NWPi.navigationController(screen) # Create a navigation view controller. Will parent all the Viewcontrollers
topLevelObjects.append(navigationViewController) # This will now be added to topLevelObjects so it can recieve events
# draw each viewController to the navigation controller
home = UI.homeViewController(navigationViewController) # Create a ViewController, from subclass homeViewController where all elements are already defined
navigationViewController.addSubView("HOMEVIEWCONTROLLER", home) # Add the ViewController to the navigation Controller. Do the same with the rest.
secondView = UI.instructionsViewController(navigationViewController)
navigationViewController.addSubView("INSTRUCTIONS", secondView)
gameView = UI.mainGameViewController(navigationViewController)
navigationViewController.addSubView("GAMEVIEW", gameView)
# We need to set a viewController to show as the top level. Choose it here:
navigationViewController.makeKeyAndVisible("INSTRUCTIONS") # Tell the navigation controller to set the view with the specified identifier to the top
# We need a loop to keep the script running. Defining it here
while True:
loop() # Run the loop() function we defined earlier.
示例5: __init__
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self,parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
sys.stdout=StdoutRedirector(self.ui.console)
#### 1: ROADMAP ####
UI.setRoadmapGUI(self)
self.ui.roadmap_widget.hide()
self.ui.roadmap_Run.clicked.connect(self.start_roadmap)
self.createTable("roadmap")
self.ui.roadmap_table.hide()
self.ui.roadmap_Options.clicked.connect(self.ui.roadmap_table.show)
self.ui.roadmap_Options.clicked.connect(self.ui.roadmap_save_button.show)
self.ui.roadmap_save_button.clicked.connect(self.saveOptions)
#### 2: POLYGONS ####
UI.setPolygonsGUI(self)
self.ui.polygons_widget.hide()
self.ui.polygons_Run.clicked.connect(self.start_polygons)
#### 3: BUILDING_GENERATION ####
self.ui.building_generation_Run.clicked.connect(UI.building_generation)
#### 4: VISUALIZATION ####
self.ui.visualization_Run.clicked.connect(UI.visualization)
示例6: doBuyArmor
def doBuyArmor(self, Player):
"""Initializes armor buy dialogue with player"""
# Generate shop inventory menu
ShopWaresMenu = UI.MenuClass()
ShopWaresMenu.Title = "Armor"
while not ShopWaresMenu.Returned:
# Fill with with items & information and trade-in value
ShopWaresMenu.clear()
for ShopItem in self.ArmorList:
Name = ShopItem.descString()
ShopWaresMenu.addItem(Name)
ShopWaresMenu.CustomText = (
"You have " + str(Player.Gold) + " gp\nYour armor: " + Player.Equipment["Armor"].Base.descString()
)
Index = ShopWaresMenu.doMenu()
if ShopWaresMenu.Returned:
break
ShopItem = self.ArmorList[Index]
if Player.Gold < ShopItem.Value:
print("You cannot afford that!")
UI.waitForKey()
continue
# Secure the transaction
self.ArmorList.remove(ShopItem)
Player.Gold -= ShopItem.Value
Player.addItem(ShopItem)
print(ShopItem.Name, "bought")
UI.waitForKey()
示例7: doExamine
def doExamine(self, Player):
"""Starts cell object examination dialogue"""
while 1:
ObjectMenu = UI.MenuClass()
ObjectMenu.Title = "Objects"
for Object in self.Items:
ObjectMenu.addItem(Object.Name)
Choice = ObjectMenu.doMenu()
if ObjectMenu.Returned: break
Chosen = self.Items[Choice]
print(Chosen.descString())
ChosenMenu = UI.MenuClass()
ChosenMenu.DoCLS = 0
ChosenMenu.addItem("Take", UI.emptyCallback, "t")
Choice = ChosenMenu.doMenu()
if ChosenMenu.Returned: continue
if Choice == 0:
self.Items.remove(Chosen)
Player.Inventory.addItem(Chosen)
print("You take", Chosen.Name)
UI.waitForKey()
示例8: contract
def contract(_):
"""Shrink the filter view."""
global is_expanded
is_expanded = False
wid["expand_frame"].grid_remove()
snd.fx("contract")
UI.flow_picker()
示例9: save
def save():
"""Saves user character progress, returns 0 on success, -1 on failure"""
global Player
FileName = UI.xInput("Enter filename to save to (default: player.dat): ", "player.dat")
FileName = "".join(("saves/", FileName))
try:
if os.path.exists(FileName):
if input("Warning! File already exists. Type \'yes\' if you want to continue: ") != "yes":
return 0
Out = open(FileName, "wb")
pickle.dump(Player, Out)
Out.close()
except Exception:
print ("Error: " + sys.exc_info()[0])
UI.waitForKey()
return -1
print("Complete")
UI.waitForKey()
return 0
示例10: load
def load():
global selected_game
all_games.clear()
for gm in config:
if gm != 'DEFAULT':
try:
new_game = Game(
gm,
int(config[gm]['SteamID']),
config[gm]['Dir'],
)
except ValueError:
pass
else:
all_games.append(new_game)
new_game.edit_gameinfo(True)
if len(all_games) == 0:
# Hide the loading screen, since it appears on top
loadScreen.main_loader.withdraw()
# Ask the user for Portal 2's location...
if not add_game(refresh_menu=False):
# they cancelled, quit
UI.quit_application()
loadScreen.main_loader.deiconify() # Show it again
selected_game = all_games[0]
示例11: filter_items
def filter_items():
"""Update items based on selected tags."""
show_wip = optionWindow.SHOW_WIP.get()
style_unlocked = StyleVarPane.tk_vars['UnlockDefault'].get() == 1
# any() or all()
func = TAG_MODES[TAG_MODE.get()]
sel_tags = [
tag
for tag, enabled
in TAGS.items()
if enabled
]
no_tags = len(sel_tags) == 0
for item in UI.pal_items:
if item.needs_unlock and not style_unlocked:
item.visible = False
continue
if item.item.is_wip and not show_wip:
item.visible = False
continue
if no_tags:
item.visible = True
else:
item_tags = item.item.filter_tags
item.visible = func(
tag in item_tags
for tag in
sel_tags
)
UI.flow_picker()
示例12: run
def run() -> None:
"""Initializes program"""
# global corpus
# may want to load excel files on a case by case basis later on
if load_excel_files:
print("Loading excel files...")
excel_setup()
print("Done")
UI.setup()
# if corpus != None:
# corpus = eval(corpus)
# UI.return_data(analyze(word))
print(
"""
Notes: some 2 part words can be analyzed, however, the results
- of the analysis of such words may be inconsistant depending on
- whether the input uses a space or an underscore to seperate them
entering default as an option when it is available will run the
- given function using a set of predetermined common words
- (see common words.txt)"""
)
while True:
interface_data = UI.interface()
if interface_data[0] == "quit":
break
elif interface_data == (None, None):
continue
UI.output_data(collect_data(interface_data))
return
示例13: breed
def breed(self, mate):
if not mate.breedable():
return
for partner in self.crew:
# no sterile or pregnant partners
if not partner.breedable():
continue
if partner.sex == mate.sex:
continue
# no fathers or mothers
if partner.crew_id == mate.mom.crew_id or partner.crew_id == mate.dad.crew_id:
continue
if mate.crew_id == partner.mom.crew_id or mate.crew_id == partner.dad.crew_id:
continue
prob = .006
# half siblings and full siblings
if mate.dad.crew_id == partner.dad.crew_id:
prob *= .01
if mate.mom.crew_id == partner.mom.crew_id:
prob *= .01
if random.random() < prob:
baby = Crewmate()
mate.breeding = True
partner.breeding = True
if mate.sex == Sex.Male:
baby.be_born(mate, partner)
else:
baby.be_born(partner, mate)
self.crew.append(baby)
print UI.inline_print(baby)+" has been born."
print "Their parents are "+mate.name+" and "+partner.name
return
示例14: downloadCurrentVersionUI
def downloadCurrentVersionUI(filename,secondary_dir,file_type,root):
continue_analysis = downloadCurrentVersion(filename,secondary_dir,file_type)
if continue_analysis == 'no' and 'nnot' not in filename:
import UI
try: root.destroy(); UI.getUserParameters('no'); sys.exit()
except Exception: sys.exit()
try: root.destroy()
except Exception(): null=[] ### Occurs when running from command-line
示例15: expand
def expand(_):
"""Expand the filter view."""
global is_expanded
is_expanded = True
wid["expand_frame"].grid(row=2, column=0, columnspan=2, sticky="NSEW")
wid["tag_list"]["height"] = TK_ROOT.winfo_height() / 48
snd.fx("expand")
UI.flow_picker()