我们从Python开源项目中,提取了以下15个代码示例,用于说明如何使用kivy.config.Config.set()。
def build(self): # Force to initialize all configs in .mobileinsight.ini # This prevents missing config due to existence of older-version .mobileinsight.ini # Work-around: force on_config_change, which would update config.ini config = self.load_config() val = int(config.get('mi_general', 'bcheck_update')) config.set('mi_general', 'bcheck_update', int(not val)) config.write() config.set('mi_general', 'bcheck_update', val) config.write() Window.borderless = False self.screens = {} self.available_screens = screens.__all__ self.screen_names = self.available_screens for i in range(len(self.available_screens)): self.screens[i] = getattr(screens, self.available_screens[i])() self.home_screen = self.screens[0] COORDINATOR.setup_analyzers() COORDINATOR.send_control('START') self.root.ids.scr_mngr.switch_to(self.screens[0])
def on_start(self): # android.stop_service() # Kill zombine service from previous app instances Config.set('kivy', 'exit_on_escape', 0) if not main_utils.is_rooted(): err_str = "MobileInsight requires root privilege. Please root your device for correct functioning." Logger.error(err_str) self.home_screen.log_error(err_str) elif not main_utils.check_diag_mode(): err_str = "The diagnostic mode is disabled. Please check your phone settings." Logger.error(err_str) self.home_screen.log_error(err_str) # content = ConfirmPopup(text=err_str) # content.bind(on_answer=self.__popup_dismiss) # self.popup = Popup(title='Diagnostic mode is not available', # content=content, # size_hint=(None, None), # size=(1200, 400), # auto_dismiss=False) # self.popup.open() else: self.privacy_check() self.check_update()
def verifyDEP_main_Cb(self, result): if not self._verifying: return outUsedRecIds = list() for r in result: if r[0]: self._verifying = False self.verify_button.text = _('Verify') displayError(r[0]) return outUsedRecIds.append(r[1]) App.get_running_app().pool.apply_async(verifyDEP_finalize_Task, (outUsedRecIds, set()), callback = self.verifyDEP_finalize_Cb)
def _hide_x11_window(self): try: # Ubuntu's Unity for some reason ignores this if there are # multiple windows stacked to a single icon on taskbar. # Unity probably calls the same thing to stack the running # programs to a single icon, which makes this command worthless. x11_command = [ 'xprop', '-name', '{}'.format(self.title), '-f', '_NET_WM_STATE', '32a', '-set', '_NET_WM_STATE', '_NET_WM_STATE_SKIP_TASKBAR' ] check_output(x11_command) except Exception as e: tb = traceback.format_exc() Logger.error( 'Notification: An error occured in {}\n' '{}'.format(self.title, tb) )
def build(self): Config.set('graphics', 'width', '700') Config.set('graphics', 'height', '50') return CaptureBox()
def new_game(self, choice='clyde'): print('new game') # get numbers of last save files to find an appropriate save file id to provide copying # make this beast a lot shorter sometime soon. Probably just iterate over files with choice in them, inc # all_tmx_files_to_db() # update seed file for any changes from tmx files before copying it to use save_number = 0 for rootdir, dir, files in os.walk(SAVE_PATH): current_number = len(fnmatch.filter(files, choice + '*.save')) if current_number > save_number: save_number = current_number save_number += 1 filename = choice + '-' + str(save_number) while os.path.isfile(SAVE_PATH + filename + '.save'): filename += '0' filename = SAVE_PATH + filename + '.save' # copy seed db file with name of filename to make a new save file copyfile(os.path.join(runpath, 'seed.db'), filename) engine = create_engine('sqlite:///' + filename) Session = sessionmaker(bind=engine) # configure session object self.db = Session() # set player flags like main_character, player_party, etc player_character_flag = self.db.query(GameFlag).filter(GameFlag.name == 'player_character').first() if not player_character_flag: player_character_flag = GameFlag() player_character_flag.name = 'player_character' player_character_flag.value = choice # MAYBE TO-DO : find clyde map object and set its coords and map_id to values for clyde choice? # FOR NOW, commit changes self.db.add(player_character_flag) self.db.commit() print('save file created...loading', filename) self.load_game(filename)
def load_game(self, filename=os.path.join(runpath, 'seed.db')): print('hitting load game') # set the db here, get current map player object was last at, and load that map engine = create_engine('sqlite:///' + filename) Session = sessionmaker(bind=engine) # configure session object self.db = Session() # until the other characters are in the db, trying to load a game with anyone but clyde will crash player_character_flag = self.db.query(GameFlag).filter(GameFlag.name == 'player_character').first() self.player_object = self.db.query(MapObject).filter(MapObject.name == player_character_flag.value).first() tilemap = self.db.query(TileMap).filter(TileMap.id == self.player_object.map_id).first() self.manager.current = 'Game' self.load_map(tilemap.file_name)
def build(self): height = 300 Config.set('graphics', 'height', height) Config.set('graphics', 'width', height * 2) return GraphView()
def build(self): self.icon = 'data/icon/segreto_icon.png' # Don't know why icon isn't set :( self.title = 'Segreto 3' self.init() return self.screenmanager
def init_config(self): Config.set("graphics", "fullscreen", 0) Config.set("graphics", "resizable", 0) Config.set("graphics", "height", 600) Config.set("graphics", "width", 600) Config.set("kivy", "exit_on_escape", 0) Config.set("input", "mouse", "mouse,multitouch_on_demand") Config.write()
def save_setting(key, value, section='General'): Config.read(SETTINGS_FILE) Config.set(section, key, value) Config.write()
def setscreen(self): if self.kivy: from kivy.config import Config Config.set('input', 'mouse', 'mouse,multitouch_on_demand') from kivy.uix.floatlayout import FloatLayout from kivy.core.window import Window from kivy.utils import platform as core_platform self.root = FloatLayout() if (self.xratio == 0) or (self.yratio == 0): if core_platform == 'android': self.screen_size = Window.size else: self.screen_size = (800, 600) self.xratio = self.screen_size[0] / 800.0 self.yratio = self.screen_size[1] / 600.0 if core_platform == 'android': Window.softinput_mode = 'pan' else: Window.size = self.screen_size else: import ui if (self.xratio == 0) or (self.yratio == 0): ss1 = ui.get_screen_size()[0] ss3 = ui.get_screen_size()[1] notoptimal = True while notoptimal: if ss1 % 8 == 0: notoptimal = False else: ss1 -= 1 ss1 = ss1 - 124 ss2 = (ss1 / 4) * 3 if ss2 > ss3: ss2 = ss3 - ss2 - ((ss3 - ss2) % 3) ss1 = (ss2 / 3) * 4 self.screen_size = (ss1, ss2) self.xratio = self.screen_size[0] / 800 self.yratio = self.screen_size[1] / 600 self.root = ui.View(frame=(0,0,self.screen_size[0], \ self.screen_size[1]))
def setscreen(self): if self.kivy: from kivy.config import Config Config.set('input', 'mouse', 'mouse,multitouch_on_demand') from kivy.uix.floatlayout import FloatLayout from kivy.core.window import Window from kivy.utils import platform as core_platform self.root = FloatLayout() if (self.xratio == 0) or (self.yratio == 0): if core_platform == 'android': self.screen_size = Window.size if self.screen_size[0] < self.screen_size[1]: x = self.screen_size[0] y = self.screen_size[0] / 4 * 3 self.screen_size = (x, y) else: self.screen_size = (800, 600) self.xratio = self.screen_size[0] / 800.0 self.yratio = self.screen_size[1] / 600.0 if core_platform == 'android': Window.softinput_mode = 'pan' else: Window.size = self.screen_size else: import ui if (self.xratio == 0) or (self.yratio == 0): ss1 = ui.get_screen_size()[0] ss3 = ui.get_screen_size()[1] notoptimal = True while notoptimal: if ss1 % 8 == 0: notoptimal = False else: ss1 -= 1 ss2 = (ss1 / 4) * 3 title_bar_height = int(ss3 / 600 * 50) if ss2 > ss3 - title_bar_height: ss2 = ss3 - title_bar_height notoptimal = True while notoptimal: if ss2 % 6 == 0: notoptimal = False else: ss2 -= 1 ss1 = (ss2 / 3) * 4 self.screen_size = (ss1, ss2) self.xratio = ss1 / 800 self.yratio = ss2 / 600 self.root = ui.View(frame=(0,0,self.screen_size[0], \ self.screen_size[1]))
def setscreen(self): if self.kivy: from kivy.config import Config Config.set('input', 'mouse', 'mouse,multitouch_on_demand') from kivy.uix.floatlayout import FloatLayout from kivy.core.window import Window from kivy.utils import platform as core_platform self.root = FloatLayout() if (self.xratio == 0) or (self.yratio == 0): if core_platform == 'android': self.screen_size = Window.size if self.screen_size[0] < self.screen_size[1]: x = self.screen_size[0] y = self.screen_size[0] / 4 * 3 self.screen_size = (x, y) else: self.screen_size = (800, 600) self.xratio = self.screen_size[0] / 800.0 self.yratio = self.screen_size[1] / 600.0 if core_platform == 'android': Window.softinput_mode = 'pan' else: Window.size = self.screen_size else: import ui if (self.xratio == 0) or (self.yratio == 0): ss1 = ui.get_screen_size()[0] ss3 = ui.get_screen_size()[1] notoptimal = True while notoptimal: if ss1 % 8 == 0: notoptimal = False else: ss1 -= 1 ss2 = (ss1 / 4) * 3 title_bar_height = int(ss3 / 600 * 90) if ss2 > ss3 - title_bar_height: ss2 = ss3 - title_bar_height notoptimal = True while notoptimal: if ss2 % 6 == 0: notoptimal = False else: ss2 -= 1 ss1 = (ss2 / 3) * 4 self.screen_size = (ss1, ss2) self.xratio = ss1 / 800 self.yratio = ss2 / 600 self.root = ui.View(frame=(0,0,self.screen_size[0], \ self.screen_size[1]))