當前位置: 首頁>>代碼示例>>Python>>正文


Python Gui.new_PushButton方法代碼示例

本文整理匯總了Python中Gui.new_PushButton方法的典型用法代碼示例。如果您正苦於以下問題:Python Gui.new_PushButton方法的具體用法?Python Gui.new_PushButton怎麽用?Python Gui.new_PushButton使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Gui的用法示例。


在下文中一共展示了Gui.new_PushButton方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import Gui [as 別名]
# 或者: from Gui import new_PushButton [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 = '~'
開發者ID:zsimic,項目名稱:TopCoderAnts,代碼行數:76,代碼來源:AntsViewer.py


注:本文中的Gui.new_PushButton方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。