def __init__(self, **kwargs): super(SimScaleBox, self).__init__(**kwargs) # set pre-saved data self.scale = eval(Config.get('simpanel', 'scale')) self.pos = (eval(Config.get('simpanel', 'posX')), eval(Config.get('simpanel', 'posY')))
def make_fake_fullscreen(self): Window.fullscreen = 0 Window.borderless = 1 Window.pos = 0, 0 Window.left = 0 Window.top = 0 width, height = int(Config.get('graphics', 'screen_width')), int( Config.get('graphics', 'screen_height')) Config.set('graphics', 'width', width) Config.set('graphics', 'height', height) Config.set('graphics', 'left', 0) Config.set('graphics', 'top', 0) Config.write() Window.size = width, height self.width, self.height = width, height
def on_touch_down(self, touch): if not self.collide_point(*touch.pos): return False self.touch_x, self.touch_y = touch.x, Window.height - touch.y self.drag_clock = Clock.schedule_interval( self._drag, 1 / int(Config.get('graphics', 'maxfps'))) return super().on_touch_down(touch)
def make_windowed(self): Window.fullscreen = 0 Window.borderless = 0 w, h = int(Config.get('graphics', 'width')), int(Config.get('graphics', 'height')) sw, sh = int(Config.get('graphics', 'screen_width')), int( Config.get('graphics', 'screen_height')) if w == sw and h == sh: w, h = int(w * 2 / 3), int(h * 2 / 3) l, t = int(sw / 2 - w / 2), int(sh / 2 - h / 2) Window.left = l Window.top = t Config.set('graphics', 'width', int(w)) Config.set('graphics', 'height', int(h)) Config.set('graphics', 'left', l) Config.set('graphics', 'top', t) Config.write() Window.size = w, h self.log(f'Window size is {w}x{h}') self.width, self.height = w, h
class SimScaleBox(Scatter): def __init__(self, **kwargs): super(SimScaleBox, self).__init__(**kwargs) # set pre-saved data self.scale = eval(Config.get('simpanel', 'scale')) self.pos = (eval(Config.get('simpanel', 'posX')), eval(Config.get('simpanel', 'posY'))) class SimPanelApp(App): """ SimPanel app. Mapped to simpanel.kv """ def build(self): return SimPanel() # Create config file at first use Config.read('simpanel.ini') try: Config.get('simpanel', 'posX') except NoSectionError: Config.add_section('simpanel') Config.set('simpanel', 'posX', 0) Config.set('simpanel', 'posY', 0) Config.set('simpanel', 'scale', 1) Config.write() pass
if isdir(vol): for drive in next(walk(vol))[1]: drives.append((vol + sep + drive, drive)) return drives class I18NFileChooserListView(FileChooserListView): font_name = StringProperty(Theme.DEFAULT_FONT) show_hidden = BooleanProperty(True) # avoid errors class I18NFileChooserListLayout(FileChooserListLayout): _ENTRY_TEMPLATE = "I18NFileListEntry" log_level = Config.get("kivy", "log_level") Config.set("kivy", "log_level", "error") Builder.load_string(""" [I18NFileListEntry@FloatLayout+TreeViewNode]: locked: False entries: [] path: ctx.path is_selected: self.path in ctx.controller().selection orientation: 'horizontal' size_hint_y: None height: '24dp' # Don't allow expansion of the ../ node is_leaf: not ctx.isdir or ctx.name.endswith('..' + ctx.sep) or self.locked on_touch_down: self.collide_point(*args[1].pos) and ctx.controller().entry_touched(self, args[1]) on_touch_up: self.collide_point(*args[1].pos) and ctx.controller().entry_released(self, args[1]) BoxLayout:
from kivy import Config from kivy.graphics.svg import Svg from kivy.lang import Builder from kivy.properties import StringProperty from kivy.uix.boxlayout import BoxLayout from kivy.uix.label import Label from kivy.uix.scatter import Scatter from kivy import Config scrH = (int(int(Config.get('graphics', 'width')) / 16 * 9)) Builder.load_string(''' <BasicWidget>: pass: "******" margin: 5 # DEBUG #canvas.before: # Color: # rgba: 1, 1, 1, .1 # Rectangle: # #pos: ((self.x + self.margin), (self.y + self.margin)) # #size: ((self.width - 2*self.margin), (self.height - 2*self.margin)) # pos: self.pos # size: self.size # \DEBUG <MonoLabel@Label> #size_hint: (None, None) size: self.texture_size font_name: "./app/frames/fonts/secrcode.ttf"
import os import sys import win32com.client import win32gui import infi.systray import yaml import itertools from window_drag_behavior import WindowDragBehavior from KivyOnTop import register_topmost register_topmost(Window, 'FFL') DESKTOP_RELOAD_INTERVAL = 10 WINDOW_HIDE_MIN_TIME = 1.5 WINDOW_HIDE_CHECK_INTERVAL = 1 / int(Config.get('graphics', 'maxfps')) def get_lnk_path(path_to_lnk): shell = win32com.client.Dispatch("WScript.Shell") shortcut = shell.CreateShortcut(path_to_lnk) return shortcut.Targetpath def get_type_string(filename): ext = os.path.splitext(filename)[1] if ext == '.lnk': ext = os.path.splitext(get_lnk_path(filename))[1] TYPES = {'': 'dir', '.exe': 'App'}
from kivy.core.window import Window from kivy.garden.contextmenu import ContextMenu, ContextMenuTextItem from kivy.graphics import Color, Rectangle, Ellipse from kivy.graphics import Translate, ScissorPush, ScissorPop, Scale from kivy.graphics.vertex_instructions import Line, Quad from kivy.lang import Builder from kivy.properties import Property from kivy.uix.popup import Popup from kivy.uix.widget import Widget from map import Map """This needs for .kv file""" ContextMenu, ContextMenuTextItem Config.set('input', 'mouse', Config.get('input', 'mouse') + ',disable_multitouch') __author__ = 'leon.ljsh' class CurrentAction(Enum): none = 0 wall = 1 headline = 2 car = 3 finish = 4 edit = 5 class MapDrawer(Widget): action = Property(CurrentAction.none)