def initUI(self): filename = os.path.basename(self.textPad.filename) vbox = QVBoxLayout() self.label = WhiteLabel(filename + ' :\n\n') self.label.setAlignment(Qt.AlignCenter) self.listWidget = ListWidget() updateButton = PushButton('Save + Update') updateButton.clicked.connect(self.update) okButton = PushButton('Ok') okButton.clicked.connect(self.onClose) hbox = QHBoxLayout() hbox.addWidget(updateButton) hbox.addWidget(okButton) vbox.addWidget(self.label) vbox.addWidget(self.listWidget) vbox.addLayout(hbox) self.setLayout(vbox) self.fillList() # signals self.listWidget.itemDoubleClicked.connect(self.gotoPos) self.show()
def __init__(self): super().__init__() visualize_button = PushButton("Visualization") visualize_button.clicked.connect(self.visualize_button_clicked) # to style it in our stylesheet visualize_button.setObjectName("bigButton") bulk_investigation_button = PushButton("Investigation / Settings") bulk_investigation_button.clicked.connect( self.bulk_investigation_button_clicked) bulk_investigation_button.setObjectName("bigButton") for button in [visualize_button, bulk_investigation_button]: font = button.font() font.setPointSize(30) button.setFont(font) expanding = QSizePolicy() expanding.setHorizontalPolicy(QSizePolicy.Expanding) expanding.setVerticalPolicy(QSizePolicy.Expanding) button.setSizePolicy(expanding) layout = QHBoxLayout() layout.addWidget(visualize_button) layout.addWidget(bulk_investigation_button) layout.setContentsMargins(15, 15, 15, 10) self.setLayout(layout)
def __init__(self): super().__init__() self._cg = None self.visualizer = None self.old_api_key = get_setting("api_key") self.loadables_q = Queue() # this thread continually checks for new loadables to load self.cg_load_thread = threading.Thread(target=self._load_loadables) # we never kill this thread, so allow the application to quit while it's # still alive self.cg_load_thread.daemon = True self.cg_load_thread.start() self.loadable_loaded = threading.Event() self.show_visualizer_window.connect(self.show_visualizer) self.show_exception_signal.connect(self.show_exception) expanding = QSizePolicy() expanding.setHorizontalPolicy(QSizePolicy.Expanding) expanding.setVerticalPolicy(QSizePolicy.Expanding) self.drop_area = ReplayDropArea() self.drop_area.setSizePolicy(expanding) da_scroll_area = QScrollArea(self) da_scroll_area.setWidget(self.drop_area) da_scroll_area.setWidgetResizable(True) da_scroll_area.setFrameShape(QFrame.NoFrame) self.replay_map_creation = ReplayMapCreation() self.replay_map_creation.setSizePolicy(expanding) rmc_scroll_area = QScrollArea(self) rmc_scroll_area.setWidget(self.replay_map_creation) rmc_scroll_area.setWidgetResizable(True) rmc_scroll_area.setFrameShape(QFrame.NoFrame) visualize_button = PushButton("Visualize") visualize_button.setObjectName("bigButton") visualize_button.clicked.connect(self.visualize) font = visualize_button.font() font.setPointSize(30) visualize_button.setFont(font) expanding = QSizePolicy() expanding.setHorizontalPolicy(QSizePolicy.Expanding) expanding.setVerticalPolicy(QSizePolicy.Expanding) visualize_button.setSizePolicy(expanding) layout = QGridLayout() layout.addWidget(da_scroll_area, 0, 0, 6, 1) layout.addWidget(rmc_scroll_area, 0, 1, 6, 1) layout.addWidget(visualize_button, 6, 0, 2, 2) self.setLayout(layout)
def __init__(self): super().__init__() self.back_button = PushButton() self.back_button.setFixedWidth(55) self.back_button.setFixedHeight(30) self.back_button.setIcon(QIcon(resource_path("back_arrow.png"))) # so we can reference just this button in css self.back_button.setObjectName("backButton") self.back_button.clicked.connect(lambda: self.set_index(0)) # offset by a bit so we're not right against the window border margins = self.back_button.contentsMargins() margins.setLeft(10) margins.setTop(10) self.back_button.setContentsMargins(margins) self.stacked_widget = QStackedWidget() window_selector = WindowSelector() window_selector.visualize_button_clicked.connect( lambda: self.set_index(1)) window_selector.bulk_investigation_button_clicked.connect( lambda: self.set_index(2)) self.analysis_selection = AnalysisSelection() self.cg_classic = CircleguardClassic() self.stacked_widget.addWidget(window_selector) self.stacked_widget.addWidget(self.analysis_selection) self.stacked_widget.addWidget(self.cg_classic) index_map = {"selection": 0, "visualization": 1, "investigation": 2} index = index_map[get_setting("default_page")] self.set_index(index) layout = QVBoxLayout() layout.addWidget(self.back_button) layout.addWidget(self.stacked_widget) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.setLayout(layout)
def __init__(self): super().__init__() self.qscrollarea = QScrollArea(self) self.qscrollarea.setWidget(ScrollableSettingsWidget()) self.qscrollarea.setAlignment(Qt.AlignCenter) self.qscrollarea.setWidgetResizable(True) self.open_settings = PushButton("Open Advanced Settings") self.open_settings.clicked.connect(self._open_settings) self.sync_settings = PushButton("Sync Settings") self.sync_settings.clicked.connect(self._sync_settings) self.info = QLabel(self) # multiple spaces get shrunk to one space in rich text mode # https://groups.google.com/forum/#!topic/qtcontribs/VDOQFUj-eIA self.info.setText( f"circleguard v{__version__} | " "<a href=\"https://discord.gg/wj35ehD\">Discord</a>" " | <a href=\"https://github.com/circleguard/circleguard/\">Github</a>" ) self.info.setTextFormat(Qt.RichText) self.info.setTextInteractionFlags(Qt.TextBrowserInteraction) self.info.setOpenExternalLinks(True) self.info.setAlignment(Qt.AlignCenter) self.setting_buttons = WidgetCombiner(self.open_settings, self.sync_settings, self) layout = QGridLayout() layout.addWidget(self.info, 0, 0, 1, 1, alignment=Qt.AlignLeft) layout.addWidget(self.setting_buttons, 0, 1, 1, 1, alignment=Qt.AlignRight) layout.addWidget(self.qscrollarea, 1, 0, 1, 2) self.setLayout(layout)
def initUI(self): vbox = QVBoxLayout() hbox = QHBoxLayout() grid = QGridLayout() runLabel = Label('Run Command: ') terminalLabel = Label('Terminal Command: ') interpreterLabel = Label('Interpreter Command: ') self.c = Configuration() system = self.c.getSystem() runCommand = self.c.getRun(system) terminalCommand = self.c.getTerminal(system) interpreterCommand = self.c.getInterpreter(system) self.runBox = QLineEdit(runCommand) self.runBox.setCursorPosition(0) self.runBox.setMinimumWidth(30) self.terminalBox = QLineEdit(terminalCommand) self.terminalBox.setCursorPosition(0) self.interpreterBox = QLineEdit(interpreterCommand) self.interpreterBox.setCursorPosition(0) okButton = PushButton('OK') okButton.pressed.connect(self.close) groupBox1 = self.createRadioGroup() groupBox2 = self.createTextPadGroup() self.checkRadio(system) grid.addWidget(runLabel, 0, 0) grid.addWidget(self.runBox, 0, 1) grid.addWidget(terminalLabel, 1, 0) grid.addWidget(self.terminalBox, 1, 1) grid.addWidget(interpreterLabel, 2, 0) grid.addWidget(self.interpreterBox, 2, 1) grid.addWidget(okButton, 4, 1) grid.addWidget(groupBox1, 3, 0) grid.addWidget(groupBox2, 3, 1) self.setLayout(grid) self.show()
def __init__(self, parent): super().__init__(parent) qscrollarea = QScrollArea(self) qscrollarea.setWidget(ScrollableThresholdsWidget(self)) qscrollarea.setWidgetResizable(True) clear_results_button = PushButton("Reset To Defaults") clear_results_button.clicked.connect(self.reset_to_defaults) clear_results_button.setMinimumHeight(27) clear_results_button.setMinimumWidth(110) layout = QVBoxLayout() layout.addWidget(qscrollarea) layout.addWidget(clear_results_button, alignment=Qt.AlignLeft) self.setLayout(layout)
def __init__(self): super().__init__() self.qscrollarea = QScrollArea(self) self.results = ResultsFrame() self.qscrollarea.setWidget(self.results) self.qscrollarea.setWidgetResizable(True) clear_results_button = PushButton("Clear Results") clear_results_button.clicked.connect(self.clear_results) clear_results_button.setMinimumHeight(27) clear_results_button.setMinimumWidth(110) layout = QGridLayout() layout.addWidget(self.qscrollarea, 0, 0, 1, 2) layout.addWidget(clear_results_button, 1, 0, 1, 1, alignment=Qt.AlignLeft) self.setLayout(layout)
def __init__(self, window): self.width = window.get_width() self.height = window.get_height() self.window = window self.running = True self.paused = False self.move = None self.mill = NineMenMorris() self.active_window = Window.MENU self.piece_being_held = False self.held_piece = -1 # Faz o rescaling das posições da tela. O jogo foi originalmente feito para o tabuleiro ter 600x600. # Mas com a adição UI foi modificado para ter 500x500. for position in range(0, 24): tile_positions[position] = [int(tile_positions[position][0] * 5 / 6 + 50), int(tile_positions[position][1] * 5 / 6 + 50)] # Carregando as imagens do jogo. self.pieces_sprites = self.load_pieces_sprites() grey_panel = pygame.image.load(os.path.join("Assets", "grey_panel.png")).convert_alpha() self.background_sprite = pygame.image.load(os.path.join("Assets", 'background.png')) self.background_sprite = pygame.transform.scale(self.background_sprite, (self.width, self.height)) self.board_sprite = pygame.image.load(os.path.join("Assets", "board.png")) self.board_sprite = pygame.transform.scale(self.board_sprite, (int(self.width * 5 / 6), int(self.height * 5 / 6))) grey_button_sprites = [ pygame.image.load(os.path.join("Assets", "grey_button.png")).convert_alpha(), pygame.image.load(os.path.join("Assets", "grey_button_pushed.png")).convert_alpha() ] pause_button_sprites = [ pygame.image.load(os.path.join("Assets", "pausar_idle.png")).convert_alpha(), pygame.image.load(os.path.join("Assets", "pausar_apertado.png")).convert_alpha() ] close_button_sprites = [ pygame.image.load(os.path.join("Assets", "fechar_idle.png")).convert_alpha(), pygame.image.load(os.path.join("Assets", "fechar_apertado.png")).convert_alpha() ] play_button_sprites = [ pygame.image.load(os.path.join("Assets", "play_idle.png")).convert_alpha(), pygame.image.load(os.path.join("Assets", "play_apertado.png")).convert_alpha() ] left_arrow_button_sprites = [ pygame.image.load(os.path.join("Assets", "grey_slider_left.png")).convert_alpha(), pygame.image.load(os.path.join("Assets", "grey_slider_left_pushed.png")).convert_alpha() ] right_arrow_button_sprites = [ pygame.image.load(os.path.join("Assets", "grey_slider_right.png")).convert_alpha(), pygame.image.load(os.path.join("Assets", "grey_slider_right_pushed.png")).convert_alpha() ] up_arrow_button_sprites = [ pygame.image.load(os.path.join("Assets", "grey_slider_up.png")).convert_alpha(), pygame.image.load(os.path.join("Assets", "grey_slider_up_pushed.png")).convert_alpha() ] down_arrow_button_sprites = [ pygame.image.load(os.path.join("Assets", "grey_slider_down.png")).convert_alpha(), pygame.image.load(os.path.join("Assets", "grey_slider_down_pushed.png")).convert_alpha() ] color_toggle_button_sprites = [ pygame.image.load(os.path.join("Assets", "white_button.png")).convert_alpha(), pygame.image.load(os.path.join("Assets", "black_button.png")).convert_alpha() ] # Cria a fonte do jogo. self.font = pygame.freetype.SysFont('Comic Sans MS', 18) # Cria os botões game_window_buttons = { 'Pause': PushButton([5, 5], 40, pause_button_sprites), 'Close': PushButton([600 - 5 - 40, 5], 40, close_button_sprites), 'Resume': PushButton([5, 5], 40, play_button_sprites), } main_window_buttons = { 'Close': PushButton([600 - 5 - 40, 5], 40, close_button_sprites), 'PlayAI': PushButton([self.width / 2 - 75, self.height / 2 - 80], [150, 40], grey_button_sprites, hint_text=Text('vs AI', 18, Color.BLACK)), 'PlayHuman': PushButton([self.width / 2 - 75, self.height / 2], [150, 40], grey_button_sprites, hint_text=Text('vs Jogador', 18, Color.BLACK)) } config_window_buttons = { 'Close': PushButton([600 - 5 - 40, 5], 40, close_button_sprites), 'Color': ToggleButton([self.width / 2 + 65, self.height / 2 - 75], [30, 30], color_toggle_button_sprites), 'Return': PushButton([40, 33], [39, 31], left_arrow_button_sprites), 'Increase': PushButton([self.width / 2 + 30, self.height / 2 + 5], [int(31*0.75), int(39*0.75)], up_arrow_button_sprites), 'Decrease': PushButton([self.width / 2 + 107, self.height / 2 + 5], [int(31*0.75), int(39*0.75)], down_arrow_button_sprites), 'Play': PushButton([self.width / 2 - 75, self.height / 2 +80], [150, 40], grey_button_sprites, hint_text=Text('JOGAR', 18, Color.BLACK)) } main_window_buttons['Close'].connect_function(self.close_game) main_window_buttons['PlayAI'].connect_function(self.change_active_window, Window.CONFIG) main_window_buttons['PlayHuman'].connect_function(self.start_match, ) game_window_buttons['Close'].connect_function(self.close_game) game_window_buttons['Pause'].connect_function(self.pause_match) game_window_buttons['Resume'].connect_function(self.resume_match) game_window_buttons['Resume'].disable() config_window_buttons['Close'].connect_function(self.close_game) config_window_buttons['Return'].connect_function(self.change_active_window, Window.MENU) config_window_buttons['Increase'].connect_function(self.change_ai_depth_level, 1) config_window_buttons['Decrease'].connect_function(self.change_ai_depth_level, -1) config_window_buttons['Play'].connect_function(self.start_match, True) main_window_panels = { 'Title': Panel([self.width / 2 - 100, 30], [200, 40], grey_panel, Border(0, Color.BLACK), Text('Trilha', 20, Color.BLACK)) } game_window_panels = { 'Move': Panel([self.width / 2 - 100, 10], [200, 30], grey_panel, Border(0, Color.BLACK), Text('Vez do Branco', 18, Color.BLACK)) } config_window_panels = { 'Title': Panel([self.width / 2 - 100, 30], [200, 40], grey_panel, Border(0, Color.BLACK), Text('Trilha', 20, Color.BLACK)), 'Color': Panel([self.width / 2 - 165, self.height / 2 - 80], [175, 40], grey_panel, Border(0, Color.BLACK), Text('Escolha sua cor:', 20, Color.BLACK)), 'Msg': Panel([self.width / 2 - 165, self.height / 2], [175, 40], grey_panel, Border(0, Color.BLACK), Text('Nível da AI:', 20, Color.BLACK)), 'AiLevel': Panel([self.width / 2 + 65, self.height / 2 + 5], [30, 30], grey_panel, Border(0, Color.BLACK), Text('1', 20, Color.BLACK)) } self.window_manager = [ Window(main_window_buttons, main_window_panels), Window(game_window_buttons, game_window_panels), Window(config_window_buttons, config_window_panels) ] self.text_stage_2 = ['Preto come uma peça', 'Branco come uma peça'] self.text_normal = ['Vez do Preto', 'Vez do Branco'] self.text_game_over = ['Preto Venceu!', 'Branco Venceu!'] self.ai_depth_level = 1 self.playing_vs_ai = None self.player_color = Player.WHITE