本文整理汇总了Python中Gui.resolved_path方法的典型用法代码示例。如果您正苦于以下问题:Python Gui.resolved_path方法的具体用法?Python Gui.resolved_path怎么用?Python Gui.resolved_path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gui
的用法示例。
在下文中一共展示了Gui.resolved_path方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_game_path
# 需要导入模块: import Gui [as 别名]
# 或者: from Gui import resolved_path [as 别名]
def set_game_path(self, path):
self.game_path = path
self.gp.folder.setText(path)
self.games = []
if os.path.isdir(Gui.resolved_path(path)):
for dirpath, dirnames, filenames in os.walk(Gui.resolved_path(path)):
# dirnames[:] = []
for fname in filenames:
fpath = os.path.join(dirpath, fname)
mgamefilename = re.compile('(.+)Vs(.+)\.([0-9]+)$')
m = mgamefilename.match(fname)
if m:
self.games.append(GameFile(fname, m.group(1), m.group(2), int(m.group(3)), fpath))
if len(self.games):
self.gp.status.setText("%d games found" % len(self.games))
self.gp.status.setPalette(Gui.BLUE_TEXT)
else:
self.gp.status.setText("No games found in '%s'" % path)
self.gp.status.setPalette(Gui.RED_TEXT)
else:
self.gp.status.setText("No folder '%s'" % path)
self.gp.status.setPalette(Gui.RED_TEXT)
self.gs.combo.clear()
self.gs.combo.addItem('Select a game')
self.games.sort(key=attrgetter('sort_key'))
for g in self.games:
self.gs.combo.addItem(str(g))
self.gp.next.setEnabled(len(self.games) > 0)
self.gs.next.setEnabled(False)
示例2: on_browse_folder
# 需要导入模块: import Gui [as 别名]
# 或者: from Gui import resolved_path [as 别名]
def on_browse_folder(self):
dialog = QtGui.QFileDialog()
dialog.setFileMode(QtGui.QFileDialog.Directory)
dialog.setOption(QtGui.QFileDialog.ShowDirsOnly, True)
path = dialog.getExistingDirectory(self, 'Directory', Gui.resolved_path(self.default_game_path))
if path:
self.set_game_path(path)
self.main_window.board_view.setFocus()
示例3: __init__
# 需要导入模块: import Gui [as 别名]
# 或者: from Gui import resolved_path [as 别名]
def __init__(self, parent = None):
QtGui.QWidget.__init__(self, parent)
Gui.set_sizing(self, 0, 1)
self.main_window = parent
self.games = []
self.default_game_path = '~/play/ants/dist'
self.loader = LoadThread()
self.loader.ready.connect(self.on_game_loaded)
self.loader.progress.connect(self.on_game_progress)
self.stack = QtGui.QStackedLayout()
# Game Path selection
self.gp = QtGui.QWidget()
self.gp.hbox = Gui.new_hbox(self.gp, 1, 6, -1)
self.gp.hbox.setContentsMargins(4, 1, 1, 1)
self.gp.folder = Gui.new_LineEdit(self.gp.hbox, '', 300)
self.gp.folder.setFocusPolicy(QtCore.Qt.NoFocus)
self.gp.browse = Gui.new_PushButton(self.gp.hbox, " Browse ", self.on_browse_folder, 1)
self.gp.status = Gui.new_Label(self.gp.hbox, 'Select folder where game replays reside', -1)
self.gp.status.setPalette(Gui.GRAY_TEXT)
self.gp.next = Gui.new_PushButton(self.gp.hbox, "Next", self.switch_to_gs, 1)
self.gp.next.setEnabled(False)
# Game Selection
self.gs = QtGui.QWidget()
self.gs.hbox = Gui.new_hbox(self.gs, 1, 6, -1)
self.gs.back = Gui.new_PushButton(self.gs.hbox, "Back", self.switch_to_gp, 1)
self.gs.combo = Gui.new_Combo(self.gs.hbox, None, self.on_game_selected, 1)
self.gs.progress_bar = QtGui.QProgressBar()
Gui.embox_and_size(self.gs.hbox, self.gs.progress_bar, None, 200)
self.gs.progress_bar.setRange(0, 100)
self.gs.progress_bar.setVisible(False)
self.gs.status = Gui.new_Label(self.gs.hbox, 'Please select a game replay', -1)
self.gs.status.setPalette(Gui.GRAY_TEXT)
self.gs.next = Gui.new_PushButton(self.gs.hbox, "Next", self.switch_to_gr, 1)
self.gs.next.setEnabled(False)
# Game running
self.gr = QtGui.QWidget()
self.gr.hbox = Gui.new_hbox(self.gr, 1, 4, -1)
self.gr.back = Gui.new_PushButton(self.gr.hbox, "Back", self.switch_to_gs, 1)
self.gr.sep1 = Gui.new_Label(self.gr.hbox, '', 12)
self.gr.play = Gui.new_PushButton(self.gr.hbox, "Play", self.on_play_pause, 1)
self.gr.speed_label = Gui.new_Label(self.gr.hbox, 'Speed:', 1)
self.gr.speed = Gui.new_Combo(self.gr.hbox, ['512x', '256x', '128x', '64x', '32x', '16x', '8x', '4x', '2x', '1x'], self.on_speed_changed, 1)
self.gr.step = Gui.new_PushButton(self.gr.hbox, "Step", self.on_step, 1)
self.gr.progress_bar = QtGui.QProgressBar()
Gui.embox_and_size(self.gr.hbox, self.gr.progress_bar, None, 100)
self.gr.progress_bar.setTextVisible(True)
self.gr.eta = Gui.new_Label(self.gr.hbox, '', 1)
self.gr.eta.setPalette(Gui.GRAY_TEXT)
# self.gr.eta.setTooltip("ETA 'til end of game at current speed")
self.gr.sep2 = Gui.new_Label(self.gr.hbox, '', 4)
self.gr.p1 = Gui.new_Label(self.gr.hbox, '', -1)
self.gr.p1.setPalette(Gui.RED_TEXT)
self.gr.p2 = Gui.new_Label(self.gr.hbox, '', -1)
self.gr.p2.setPalette(Gui.BLUE_TEXT)
self.gr.status = Gui.new_Label(self.gr.hbox, '', -1)
self.gr.status.setPalette(Gui.GRAY_TEXT)
self.gr.fog = Gui.new_CheckBox(self.gr.hbox, 'Fog', self.on_fog, 1)
self.gr.fog.setChecked(True)
# timer
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.run_turn)
self.on_speed_changed(0)
# Stack
self.stack.addWidget(self.gp)
self.stack.addWidget(self.gs)
self.stack.addWidget(self.gr)
self.stack.setCurrentIndex(0)
self.setLayout(self.stack)
if os.path.isdir(Gui.resolved_path(self.default_game_path)):
self.set_game_path(self.default_game_path)
if len(self.games):
self.switch_to_gs()
else:
self.default_game_path = '~'