def OnInit(self): print('Running wxPython ' + wx.version()) # Set Current directory to the one containing this file os.chdir(os.path.dirname(os.path.abspath(__file__))) self.SetAppName('SettingsManager') s = SettingsManager() s.ReadSettings() self._snglInstChecker = wx.SingleInstanceChecker() self._snglInstChecker.CreateDefault() if self._snglInstChecker.IsAnotherRunning( ) and not s.MultipleInstancesAllowed: wx.MessageBox( 'Another instance of this application is already running!', 'Multiple instances not allowed', wx.OK | wx.ICON_EXCLAMATION | wx.CENTER) return False # Create the main window frm = MainFrame() self.SetTopWindow(frm) frm.Show() return True
def _applySettings(self): s = SettingsManager() iIndex = wx.NOT_FOUND if self.optStartType[0].GetValue() is True: for i, o in enumerate(self.optDefPos): if o.GetValue() is True: iIndex = i break iStartPos = wx.ALIGN_NOT if iIndex > wx.NOT_FOUND: iH = 0 if iIndex in [0, 3, 6]: iH = wx.LEFT elif iIndex in [1, 4, 7]: iH = wx.CENTER else: iH = wx.RIGHT iV = 0 if (iIndex > -1) and (iIndex < 3): iV = wx.TOP elif (iIndex > 2) and (iIndex < 6): iV = wx.CENTER else: iV = wx.BOTTOM if (iH == wx.CENTER) and (iV == wx.CENTER): iStartPos = (wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL) else: iStartPos = iH | iV s.MainWndStartupPos = iStartPos s.MultipleInstancesAllowed = self.chkSingleInstance.IsChecked( ) is False s.CompressSettingsFile = self.chkCompFile.IsChecked() self.btnApply.Disable()
def __init__(self): super(MainWindow, self).__init__() self.grass_result: Grasser.GrassResult self.settings_manager = SettingsManager() self.settings_manager.setup_settings(self) self.grasser = GoogleGrasser( config_file_name=self.config_file_name, service_url=self.google_translate_service_url, no_english=self.random_grass_no_english) self.config_manager = ConfigManager(self.config_file_name) self.change_style(self.application_style) self.ui = Ui_application() self.ui.setupUi(self) self.ui.select_config.addItems(["随机"] + self.config_manager.return_all_config()) self.ui.select_google_translate_url.addItems(constants.SERVICE_URLS) self.ui.select_application_style.addItems(QStyleFactory.keys()) self.GrassingThread = QThread(self) self.OnClick = OnClick(self) self.OnClick.moveToThread(self.GrassingThread) self.ui.start_grass.clicked.connect(self.on_start_grass_click) self.ui.open_file.clicked.connect(self.on_open_file_click) self.ui.copy_result.clicked.connect(self.on_copy_result_click) self.ui.save_this_grass_as_config.clicked.connect( self.on_save_this_grass_as_config_click) self.ui.save_result.clicked.connect(self.on_save_grass_result_click) self.OnClick.set_grass_result.connect(self.set_grass_result) self.OnClick.warning.connect(self.warning_dialog) self.OnClick.quit.connect(self.quit_onclick_thread) self.ui.select_google_translate_url.currentTextChanged.connect( self.on_select_google_translate_url_current_index_changed) self.GrassingThread.started.connect( lambda: self.OnClick.on_start_grass_click( self.grasser, self.ui.original_text_edit.toPlainText(), self.ui.grass_frequency.value(), self.ui.select_config.currentText())) self.ui.second_setting_option_button_group.buttonClicked.connect( self.on_second_setting_option_click) self.ui.set_config_file_name.returnPressed.connect( self.on_set_config_file_name_return_pressed) self.ui.select_application_style.currentTextChanged.connect( self.select_application_style_current_index_changed) self.ui.select_google_translate_url.setCurrentIndex( constants.SERVICE_URLS.index(self.google_translate_service_url)) self.ui.select_application_style.setCurrentIndex( QStyleFactory.keys().index(self.application_style)) if self.random_grass_no_english: self.ui.radio_first_setting_option.setChecked(True) else: self.ui.radio_second_setting_option.setChecked(True)
def select(self): if self.selection == -1: return if self.selection == ControlSettings.INDEX_RESET: SettingsManager.reset_controls() self.set_selection(0) return Globals.STATE = SetJoystickKeyState( self.surf_rect_pairs[self.selection].surf_arr[0], list_index=self.selection, return_state=self)
def _onWindowResized(self, evt): if not self.IsShown(): return s = SettingsManager() if self.IsMaximized(): s.MainWndStartupPos = wx.DefaultPosition s.MainWndStartupSize = wx.DefaultSize else: s.MainWndStartupRect = self.GetRect() evt.Skip()
def __init__(self): self.player = None #New Player self.app = QApplication([]) dir_ = QDir("fonts") #Set working directory #Set application details and icon self.app.setApplicationName("Chess Player") self.app.setApplicationDisplayName("Chess Player") self.app.setWindowIcon(QIcon("icons/chess_icon.ico")) #Get SettingsManager Instance self.settingsManager = SettingsManager()
def initialize(self): pygame.init() Globals.WIDTH = 1000 Globals.HEIGHT = 600 Globals.SCREEN = pygame.display.set_mode( (Globals.WIDTH, Globals.HEIGHT)) SettingsManager.load() Globals.set_brightness(SettingsManager.BRIGHTNESS, save=False) Globals.set_volume(SettingsManager.VOLUME, save=False) pygame.display.set_caption('The Crazy Six - Field Day') Globals.STATE = Title() Globals.EVENT_MANAGER = EventManager()
def set_brightness(brightness, save=True): if Globals.BRIGHTNESS_SURF is None: Globals.BRIGHTNESS_SURF = \ pygame.Surface((Globals.WIDTH, Globals.HEIGHT)) Globals.BRIGHTNESS_SURF.fill((0, 0, 0)) if save: SettingsManager.set_brightness(brightness) if SettingsManager.BRIGHTNESS == 100: Globals.USE_BRIGHTNESS = False else: Globals.USE_BRIGHTNESS = True Globals.BRIGHTNESS_SURF.set_alpha(int( (1 - brightness / 100) * 255))
def _fillControls(self): s = SettingsManager() iStartPos, _ = s.MainWndStartupPos if iStartPos == wx.ALIGN_NOT: self.optStartType[1].SetValue(True) self.optDefPos[4].SetValue(True) else: self.optStartType[0].SetValue(True) if iStartPos == (wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL): self.optDefPos[4].SetValue(True) else: iX = 0 if (iStartPos & wx.RIGHT) == wx.RIGHT: iX = 2 elif (iStartPos & wx.LEFT) == wx.LEFT: iX = 0 else: iX = 1 iY = 0 if (iStartPos & wx.BOTTOM) == wx.BOTTOM: iY = 6 elif (iStartPos & wx.TOP) == wx.TOP: iY = 0 else: iY = 3 self.optDefPos[iX + iY].SetValue(True) self.OnStartupPosTypeChanged(None) self.chkSingleInstance.SetValue(s.MultipleInstancesAllowed is False) self.chkCompFile.SetValue(s.CompressSettingsFile) self.btnApply.Disable()
def run(self): """ This sets up a Tribler session, loads the managers and the XML-RPC server. :return: Nothing. """ _logger.error("Loading XMLRPCServer") self.xmlrpc = XMLRPCServer(iface="0.0.0.0", port=8000) _logger.error("Loading TriblerSessionService") self.tribler = TriblerSession(self.xmlrpc) self.tribler.start_session() # Wait for dispersy to initialize while not self.tribler.is_running(): time.sleep(0.1) # Disable ChannelManager #_logger.error("Loading ChannelManager") #self.cm = ChannelManager.getInstance(self.tribler.get_session(), self.xmlrpc) _logger.error("Loading TorrentManager") self.tm = TorrentManager.getInstance(self.tribler.get_session(), self.xmlrpc) _logger.error("Loading DownloadManager") self.dm = DownloadManager.getInstance(self.tribler.get_session(), self.xmlrpc) _logger.error("Loading ConfigurationManager") # Load this last because it sets settings in other managers self.sm = SettingsManager.getInstance(self.tribler.get_session(), self.xmlrpc) _logger.error("Now running XMLRPC on http://%s:%s/tribler" % (self.xmlrpc._iface, self.xmlrpc._port)) self.xmlrpc.start_server()
def __init__(self, iface): # initialise plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QtCore.QSettings().value("locale/userLocale")[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'essTools_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QtCore.QTranslator() self.translator.load(locale_path) if QtCore.qVersion() > '4.3.3': QtCore.QCoreApplication.installTranslator(self.translator) # Save reference to the QGIS interface self.iface = iface self.toolbar = self.iface.addToolBar(u"Space Syntax Toolkit") self.menu = self.tr(u"&Space Syntax Toolkit") self.actions = [] # Create toolkit components self.settings = SettingsManager(self.iface) self.settings_action = None self.project = ProjectManager(self.iface, self.settings) self.project_action = None self.about = AboutDialog() self.about_action = None # for remote debugging if has_pydevd and is_debug: pydevd.settrace('localhost', port=53100, stdoutToServer=True, stderrToServer=True, suspend=False) ########### ########### # initialise the different modules self.analysis = AnalysisTool.AnalysisTool(self.iface, self.settings, self.project) self.explorer = ExplorerTool.ExplorerTool(self.iface, self.settings, self.project) self.gate_transformer = TransformerAnalysis.GateTransformer(self.iface) self.rcl_cleaner = RoadNetworkCleanerTool.RoadNetworkCleaner( self.iface) self.catchment_tool = CatchmentAnalyser.CatchmentTool(self.iface) self.udi_tool = UrbanDataInputTool.UrbanDataInputTool(self.iface)
def set_event(self, event): pair = self.convert_event(event) SettingsManager.EVENTS_UP = [ a for a in SettingsManager.EVENTS_UP if a != event] SettingsManager.EVENTS_DOWN = [ a for a in SettingsManager.EVENTS_DOWN if a != event] SettingsManager.EVENTS_LEFT = [ a for a in SettingsManager.EVENTS_LEFT if a != event] SettingsManager.EVENTS_RIGHT = [ a for a in SettingsManager.EVENTS_RIGHT if a != event] SettingsManager.EVENTS_ATTACK = [ a for a in SettingsManager.EVENTS_ATTACK if a != event] SettingsManager.EVENTS_ACTION = [ a for a in SettingsManager.EVENTS_ACTION if a != event] SettingsManager.EVENTS_ESCAPE = [ a for a in SettingsManager.EVENTS_ESCAPE if a != event] SettingsManager.EVENTS_RETURN = [ a for a in SettingsManager.EVENTS_RETURN if a != event] SettingsManager.EVENTS_BACKSPACE = [ a for a in SettingsManager.EVENTS_BACKSPACE if a != event] self.get_event_list().append(pair) SettingsManager.save() self.handle_escape()
def __init__(self, iface): # initialise plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QtCore.QSettings().value("locale/userLocale")[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'essTools_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QtCore.QTranslator() self.translator.load(locale_path) if QtCore.qVersion() > '4.3.3': QtCore.QCoreApplication.installTranslator(self.translator) # Save reference to the QGIS interface self.iface = iface self.esst_toolbar = self.iface.addToolBar(u"Space Syntax Toolkit") # initialise base modules and interface actions self.settings = SettingsManager(self.iface) self.settings_action = None self.project = ProjectManager(self.iface, self.settings) self.project_action = None # initialise the tool modules and interface actions self.analysis = AnalysisTool.AnalysisTool(self.iface, self.settings, self.project) self.analysis_action = None self.explorer = ExplorerTool.ExplorerTool(self.iface, self.settings, self.project) self.explorer_action = None # Create other dialogs self.about = AboutDialog() about_msg = ( 'The "Space Syntax Toolkit" was originally developed at the Space Syntax Laboratory, ' 'the Bartlett School of Architecture, University College London (UCL).\n\n' 'Author: Jorge Gil\n\n' 'Contributors: Tasos Varoudis\n\n' 'Contact: [email protected]\n\n' 'Released under GNU Licence version 3') self.about.messageText.setText(about_msg) self.about.logoLabel.setPixmap(QPixmap(os.path.dirname(__file__) + '/icons/ucl.png')) self.about.logoLabel.setScaledContents(True) self.about_action = None self.help_action = None # initialise default events #self.project.loadSettings() if has_pydevd and is_debug: pydevd.settrace('localhost', port=53100, stdoutToServer=True, stderrToServer=True, suspend=False)
def __init__(self, iface): # initialise plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QtCore.QSettings().value("locale/userLocale")[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'essTools_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QtCore.QTranslator() self.translator.load(locale_path) if QtCore.qVersion() > '4.3.3': QtCore.QCoreApplication.installTranslator(self.translator) # Save reference to the QGIS interface self.iface = iface self.esst_toolbar = self.iface.addToolBar(u"Space Syntax Toolkit") # initialise base modules and interface actions self.settings = SettingsManager(self.iface) self.settings_action = None self.project = ProjectManager(self.iface, self.settings) self.project_action = None # initialise the tool modules and interface actions self.analysis = AnalysisTool.AnalysisTool(self.iface, self.settings, self.project) self.analysis_action = None self.explorer = ExplorerTool.ExplorerTool(self.iface, self.settings, self.project) self.explorer_action = None # Create other dialogs self.about = AboutDialog() self.about_action = None self.help_action = None # initialise default events #self.project.loadSettings() if has_pydevd and is_debug: pydevd.settrace('localhost', port=53100, stdoutToServer=True, stderrToServer=True)
def __init__(self): wx.Frame.__init__(self, None, title=wx.GetApp().GetAppName()) self.SetIcon(wx.Icon('../../common/wxwin.ico')) self._createControls() # Minimum client size of the main window self.SetMinClientSize(wx.Size(400, 300)) s = SettingsManager() mode, pos = s.MainWndStartupPos sz = s.MainWndStartupSize if mode == wx.ALIGN_NOT: if sz == wx.DefaultSize: if pos == wx.DefaultPosition: self.Maximize() else: self.CenterOnScreen() else: self.Move(pos) self.SetSize(sz) else: iWScr, iHScr = wx.GetDisplaySize() if sz == wx.DefaultSize: sz = self.GetSize() pt = wx.DefaultPosition if (mode & wx.LEFT) == wx.LEFT: pt.x = 0 elif (mode & wx.RIGHT) == wx.RIGHT: pt.x = iWScr - sz.GetWidth() else: pt.x = (iWScr - sz.GetWidth()) / 2 if (mode & wx.TOP) == wx.TOP: pt.y = 0 elif (mode & wx.BOTTOM) == wx.BOTTOM: pt.y = iHScr - sz.GetHeight() else: pt.y = (iHScr - sz.GetHeight()) / 2 self.Move(pt) self.SetSize(sz) self._connectControls()
def __init__(self): """ Constructs a new PipelineSettingsManager. Remember to call loadFromFile to load actual settings instead of the defaults. """ SettingsManager.__init__(self, "PipelineSettings")
def OnExit(self): s = SettingsManager() if s.Modified is True: s.SaveSettings() return wx.App.OnExit(self)
def main(argc, argv): # The default profile settings for the application default_settings = { 'subreddits': {}, 'profile_name': 'Default', 'center_image': False, 'mirror_image': False, 'fill_voidspace': False, 'fill_behavior': { 'solid_fill': False, 'random_fill': False, 'smart_fill': False }, 'fill_color': '#000000', 'max_scale_factor': 1.7, 'chaos_tolerance': 100, 'images_to_download': 50, 'download_interval': 86400 } # Create a JsonHandler object to handle importing and exporting profile data json_handler = JsonHandler(filename=DATABASE_FILENAME, json_data=default_settings) # Create a SettingsManager to handle the GUI elements of the application (collecting user settings) settings_manager = SettingsManager(settings_dict=json_handler.json_data, database=json_handler) # The SettingsManager works best in Windows when it's run in its own thread # NOTE: After some changes this is no longer the case. Do not revise this code segment # until after threaded functionality is removed from SettingsManager if sys.platform in supported_platforms: if sys.platform == 'darwin': settings_manager.run() elif sys.platform == 'win32': # settings_manager.start() # settings_manager.join() settings_manager.run() else: print('Unknown platform. Exiting...') sys.exit(1) # If the settings_manager exited while launch set to True (if the user pressed 'launch' to exit the menu) if settings_manager.launch: # Create a new RedditInterface to handle requesting posts reddit_interface = RedditInterface( settings_dict=json_handler.json_data) reddit_interface.get_images() # Create a new ImageHandler image_folder_location = downloaded_image_folder_location image_handler = ImageHandler(image_folder_location, json_handler.json_data) # Do not use any images that fail the resolution check image_handler.flush_images_by_resolution() # Resize images and perform other operations based on user settings image_handler.resize_images() # Create a timer object and set it on a loop """
import os import cv2 as cv import sysv_ipc as ipc import time from subprocess import call from threading import Thread from InputManager import InputManager from SettingsManager import SettingsManager from LedDriver import LedDriver from StateMachine import StateMachine from SACOnScreenDisplay.OSD import OSD from picamera.array import PiRGBArray from picamera import PiCamera settingsManager = SettingsManager() inputManager = InputManager(5, 6, 13) ledDriver = LedDriver(17, 27, 22) stateMachine = StateMachine(settingsManager, ledDriver) osd = OSD(inputManager, settingsManager) # Target screen is 12", 1024x768 or 768x1024 in portrait mode screenWidth = 768 screenHeight = 1024 # Sensor size is 80x60 sensorWidth = 80 sensorHeight = 60 # Lepton offset in degC corrVal = 0 maxVal = 0 feverThresh = 35.4
class MainChessApp(): """ The main application class """ def __init__(self): self.player = None #New Player self.app = QApplication([]) dir_ = QDir("fonts") #Set working directory #Set application details and icon self.app.setApplicationName("Chess Player") self.app.setApplicationDisplayName("Chess Player") self.app.setWindowIcon(QIcon("icons/chess_icon.ico")) #Get SettingsManager Instance self.settingsManager = SettingsManager() def buildUI(self): """ Build main window UI """ #Add The font _id = QFontDatabase.addApplicationFont("fonts/CenturyGothic.ttf") #set the application style self.setAppStyle() #Configure Window self.mainWindow = QWidget() self.mainWindow.setObjectName('window') self.mainWindow.setWindowTitle("Chess Player") #Window main layout v_layout = QVBoxLayout() # mainWindow layout h_layout = QHBoxLayout() # Placeholder for mainWindow buttons #Top Section logo = QLabel("Chess Player") logo_font = QFont("CenturyGothic", 38, QFont.Bold) logo.setFont(logo_font) logo.setStyleSheet("color: #0B5394;") v_layout.addWidget(logo) #Bottom Section self.capture_button = QPushButton("Start Capturing Board") self.capture_button.clicked.connect(self.captureBoard) self.motivation_button = QPushButton("Last Move") self.motivation_button.clicked.connect(lambda: self.showLastMove()) self.settings_button = QPushButton("Settings") self.settings_button.clicked.connect(self.openSettings) h_layout.addWidget(self.capture_button) h_layout.addWidget(self.motivation_button) h_layout.addWidget(self.settings_button) #Finalize layout v_layout.addLayout(h_layout) self.mainWindow.setLayout(v_layout) #Configure Window settings self.mainWindow.setFixedSize( self.mainWindow.sizeHint()) #Disable resize self.mainWindow.show() self.app.exec_() def setAppStyle(self): """ Change the application stylesheet """ self.app.setStyleSheet(app_styles) def changePlayerBoard(self, fen): """ Update the ChessPlayer Board """ if (self.player is None): self.player = ChessPlayer(fen.replace( "-", "/")) #replace fen output for futher processing else: self.player.setBoard(fen.replace( "-", "/")) #replace fen output for futher processing def captureBoard(self): """ Extract Board from the user's screen """ img = get_screen_image(self.mainWindow) board_found, board_image = extract_board(img) if (board_found): fen = extract_fen(board_image) self.changePlayerBoard(fen) self.player.setOutBoard( board_image) #change the output board image self.player.startBoardConfig( ) #Open the board configuration window else: QMessageBox.warning( self.mainWindow, 'Chess Player - No Board Found', "Couldn't find a chess board from your screen.", QMessageBox.Ok, QMessageBox.Ok) def openSettings(self): """ Open settings menu for potential modifications """ self.settingsManager.createUI() self.settingsManager.showUI() def showLastMove(self): """ Retrieve the last image produced by the ChessPlayer """ if self.player is not None and self.player.getLastMoveImage( ) is not None: cv2.imshow('Chess Player - The last move was', self.player.getLastMoveImage()) else: msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText( "You need to capture at least one board to show you the last move" ) msg.setWindowTitle("Chess Player - Nothing to show") msg.setStandardButtons(QMessageBox.Ok) msg.exec()
def __init__(self): SettingsManager.__init__(self, "VoxelSettings")
class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.grass_result: Grasser.GrassResult self.settings_manager = SettingsManager() self.settings_manager.setup_settings(self) self.grasser = GoogleGrasser( config_file_name=self.config_file_name, service_url=self.google_translate_service_url, no_english=self.random_grass_no_english) self.config_manager = ConfigManager(self.config_file_name) self.change_style(self.application_style) self.ui = Ui_application() self.ui.setupUi(self) self.ui.select_config.addItems(["随机"] + self.config_manager.return_all_config()) self.ui.select_google_translate_url.addItems(constants.SERVICE_URLS) self.ui.select_application_style.addItems(QStyleFactory.keys()) self.GrassingThread = QThread(self) self.OnClick = OnClick(self) self.OnClick.moveToThread(self.GrassingThread) self.ui.start_grass.clicked.connect(self.on_start_grass_click) self.ui.open_file.clicked.connect(self.on_open_file_click) self.ui.copy_result.clicked.connect(self.on_copy_result_click) self.ui.save_this_grass_as_config.clicked.connect( self.on_save_this_grass_as_config_click) self.ui.save_result.clicked.connect(self.on_save_grass_result_click) self.OnClick.set_grass_result.connect(self.set_grass_result) self.OnClick.warning.connect(self.warning_dialog) self.OnClick.quit.connect(self.quit_onclick_thread) self.ui.select_google_translate_url.currentTextChanged.connect( self.on_select_google_translate_url_current_index_changed) self.GrassingThread.started.connect( lambda: self.OnClick.on_start_grass_click( self.grasser, self.ui.original_text_edit.toPlainText(), self.ui.grass_frequency.value(), self.ui.select_config.currentText())) self.ui.second_setting_option_button_group.buttonClicked.connect( self.on_second_setting_option_click) self.ui.set_config_file_name.returnPressed.connect( self.on_set_config_file_name_return_pressed) self.ui.select_application_style.currentTextChanged.connect( self.select_application_style_current_index_changed) self.ui.select_google_translate_url.setCurrentIndex( constants.SERVICE_URLS.index(self.google_translate_service_url)) self.ui.select_application_style.setCurrentIndex( QStyleFactory.keys().index(self.application_style)) if self.random_grass_no_english: self.ui.radio_first_setting_option.setChecked(True) else: self.ui.radio_second_setting_option.setChecked(True) def on_start_grass_click(self) -> None: self.GrassingThread.start() def on_open_file_click(self) -> None: file_name = QFileDialog.getOpenFileName(self, "选择要生草的txt文件", "", "Txt files(*.txt)") if file_name[0] != "": with open(file_name[0], "r+", encoding="utf-8") as file: text = file.read() self.ui.original_text_edit.setPlainText(text) def on_copy_result_click(self) -> None: pyperclip.copy(self.grass_result.text) def on_save_this_grass_as_config_click(self) -> None: if "grass_result" in vars(self): config_name, ok_pressed = QInputDialog.getText( self, "输入配置名称", "名称:", QLineEdit.Normal, "") if ok_pressed: self.config_manager.new_config(self.grass_result.language_list, config_name) else: self.warning_dialog("错误", "没有生草结果,无法生成配置") def on_save_grass_result_click(self) -> None: if "grass_result" in vars(self): file_path, ok_pressed = QFileDialog.getSaveFileName( self, "保存生草结果文件", "", "txt类型 (*.txt)") if ok_pressed: with open(file_path, "w+") as output_file: output_file.write(self.grass_result.text) else: self.warning_dialog("错误", "没有生草结果,无法保存文件") def on_output_google_voice_click(self) -> None: file_name, ok_pressed = QInputDialog.getText(self, "请输入文件名", "文件名", QLineEdit.Normal) if ok_pressed: self.GrassingThread.started.connect( lambda: self.OnClick.on_output_google_voice_click(file_name)) def on_select_google_translate_url_current_index_changed(self) -> None: service_url = self.ui.select_google_translate_url.currentText() self.settings_manager.manage_setting("google_translate_service_url", service_url) def on_second_setting_option_click(self) -> None: self.settings_manager.manage_setting( "random_grass_no_english", True if self.ui.second_setting_option_button_group.checkedButton().text() == "是" else False) def on_set_config_file_name_return_pressed(self) -> None: self.settings_manager.manage_setting( "config_file_name", self.ui.set_config_file_name.text()) def select_application_style_current_index_changed(self): self.settings_manager.manage_setting( "application_style", self.ui.select_application_style.currentText()) def set_grass_result(self, grass_result: Grasser.GrassResult) -> None: self.ui.grass_result_browser.setText(grass_result.text) vars(self)["grass_result"] = grass_result def quit_onclick_thread(self) -> None: self.GrassingThread.quit() def warning_dialog(self, title: str, content_text: str) -> None: QMessageBox(QMessageBox.Warning, title, content_text, parent=self).exec_() @staticmethod def change_style(style_name: str) -> None: styles = QStyleFactory.keys() if style_name not in styles: QApplication.setStyle(styles[0]) raise NameError("没有此主题,使用默认主题") else: QApplication.setStyle(style_name)
def _onWindowMoved(self, evt): if not self.IsShown(): return SettingsManager().MainWndStartupRect = self.GetRect() evt.Skip()
print 'BACKSPACE RELEASE' def handle_return(self): print 'RETURN' def handle_return_keyup(self): print 'RETURN RELEASE' def handle_escape(self): print 'ESCAPE' def handle_escape_keyup(self): print 'ESCAPE RELEASE' def render(self): Globals.SCREEN.fill((0, 0, 0)) if __name__ == '__main__': SettingsManager.load() Globals.EVENT_MANAGER = EventManager() Globals.STATE = TestInput() pygame.init() Globals.WIDTH = 150 Globals.HEIGHT = 150 Globals.SCREEN = pygame.display.set_mode((Globals.WIDTH, Globals.HEIGHT)) while Globals.RUNNING: Globals.STATE.render() pygame.display.flip() Globals.EVENT_MANAGER.check_events()
def set_volume(volume, save=True): if save: SettingsManager.set_volume(volume) AssetLoader.set_volume(volume / 100)