def __init__(self, **kwargs): super(radar, self).__init__(**kwargs) self._radar = ScatterLayout(size=(self.width_radar, self.height_radar), do_rotate=False, do_scale=False, do_translation=False) _img_radar = Image(source='radar_1.png', size=(self.width_radar, self.height_radar), allow_stretch=True) self._sweeperGauge = ScatterLayout(size=(self.width_radar, self.height_radar), do_rotate=False, do_scale=False, do_translation=False) self._img_sweeper = Image(source='Sweeper.png', size=(self.width_radar, self.height_radar), allow_stretch=True) self._radar.add_widget(_img_radar) self.add_widget(self._radar) self.add_widget(self._sweeperGauge) self._sweeperGauge.add_widget(self._img_sweeper) self.bind(pos=self._update) self.bind(size=self._update) self.bind(value=self._aniSweep)
def build(self, testMode=True): """ Initiate objects and views. """ ''' init game objects ''' self.deck = Deck() self.evaluator = Evaluator() self.player = [] self.player.append(Player(0)) self.player.append(Player(1)) # board stands for public cards on board self.board = Board() # In test mode, both player select right-most cards for the turn automatically self.testMode = testMode ''' create view objects ''' # Scatter that can be rotated to display players scatter_bot = ScatterLayout(do_rotation=False, do_translation=False, do_scale=False, size_hint=(1, 1), pos_hint={ 'x': 0, 'y': 0 }, rotation=0) # For player on top, the widget rotates 180 degree scatter_top = ScatterLayout(do_rotation=False, do_translation=False, do_scale=False, size_hint=(1, 1), pos_hint={ 'x': 0, 'y': 0 }, rotation=180) box = PlayerDeck() box2 = PlayerDeck() publicArea = PublicArea() box.build(self, "player1", 0, self.testMode) box2.build(self, "player2", 1, self.testMode) publicArea.build() scatter_bot.add_widget(box) scatter_top.add_widget(box2) self.add_widget(scatter_bot) self.add_widget(scatter_top) self.add_widget(publicArea) # register id of view objects self.ids[box.id] = box self.ids[box2.id] = box2 self.ids[publicArea.id] = publicArea
def build(self): main_widget = ScatterLayout() map_file_path = 'test/assets/testmap.tmx' def add_widgets(): Logger.debug( 'TiledApp: creating tile map using map file: {}'.format( map_file_path)) tile_map = TileMap(map_file_path) Logger.debug('TiledApp: adding tile map to main widget') main_widget.add_widget(tile_map) Logger.debug('TiledApp: creating TileMovement widget') tile_movement = TileMovement(tile_map) tile_movement.debug() tile_movement.size_hint = 0.1, 0.1 #main_widget.add_widget(tile_movement) def move_demo(): direction = tile_movement.RIGHT Logger.debug('move_demo: moving {}'.format(direction)) tile_movement.move(direction) #Clock.schedule_interval(lambda *args: move_demo(), 2) Clock.schedule_once(lambda *args: add_widgets()) return main_widget
def main_base_menu(build_place): scatter = ScatterLayout() menu = building.MenuLayout() inside_menu = building.InsideMenuLayout() main_box = BoxLayout(orientation='horizontal') left_box = BoxLayout(orientation='vertical', size_hint_x=.35) right_box = BoxLayout(size_hint_x=.65) icon_bottom_box = BoxLayout(size_hint=(.9, .8)) icon_layout = BoxLayout(size_hint_y=.4) # pos_hint=({'top': 1}) # Вывод производства ресурсов stat_res = res_generation('main_base') # Добавление вкладок Здания tb = TabbedPanel(do_default_tab=False, tab_width=130) base_e = TabbedPanelItem(text='Энергия') base_e.content = base_energy() base_f = TabbedPanelItem(text='Пища') base_f.content = base_food() tb.add_widget(base_e) tb.add_widget(base_f) icon_bottom_box.add_widget(stat_res) icon_layout.add_widget(Image(source='data/images/buildings/main-base.png')) left_box.add_widget(icon_layout) left_box.add_widget(icon_bottom_box) right_box.add_widget(tb) main_box.add_widget(left_box) main_box.add_widget(right_box) inside_menu.add_widget(main_box) close_b = building.CloseMenuButton(build_place, scatter) menu.add_widget(inside_menu) menu.add_widget(close_b) scatter.add_widget(menu) return scatter
def build(self): # pylint: disable=no-self-use; # pragma: no cover """Called when the app is created.""" layout = ScatterLayout(translation_touches=2, do_rotation=False, scale_min=0.2, scale_max=1.5) layout.add_widget(self._grid_widget) return layout
def __init__(self, **kwargs): super(ListScreen, self).__init__(**kwargs) layout = BoxLayout(orientation='vertical') self.add_widget(layout) top_buttons = BoxLayout(orientation='horizontal') layout.add_widget(top_buttons) bottom_buttons = ScatterLayout() layout.add_widget(bottom_buttons) top_buttons.add_widget(Button(text='Save')) top_buttons.add_widget(Button(text='Dave Doty'))
def build(self): appLayout = FloatLayout(size=(800, 600)) bg = Image(source='Images/Metal2.jpg', pos=(0, 0), size=(1500, 840)) g1 = Gauge() g1s = ScatterLayout(scale=0.5, size=g1.size, pos=(30, 80)) g1s.add_widget(g1) g2 = Gauge() g2s = ScatterLayout(scale=0.5, size=g1.size, pos=(200, 80)) g2s.add_widget(g2) g3 = Gauge() g3s = ScatterLayout(scale=0.5, size=g1.size, pos=(300, 80)) g3s.add_widget(g3) head = Header() headscat = Scatter(size=head.size, pos=(0, 530), do_translation=False) headscat.add_widget(head) foot = Footer() Footer.updatedate(foot) #Clock.schedule_interval(foot.updatetime, 1) Clock.schedule_interval(partial(Footer.updatetime, foot), 1) Clock.schedule_interval(partial(Footer.updatedate, foot), 3600) #footscat = Scatter(size=foot.size, pos=(0,-10), do_translation=False) #footscat.add_widget(foot) appLayout.add_widget(bg) appLayout.add_widget(g1s) appLayout.add_widget(g2s) appLayout.add_widget(g3s) appLayout.add_widget(headscat) appLayout.add_widget(foot) Window.size = (800, 600) return appLayout
def __init__(self, **kwargs): super(ship, self).__init__(**kwargs) self._ship = ScatterLayout(size=(self.width_ship, self.height_ship), do_rotate=False, do_scale=False, do_translation=False) self._img_ship = Image(source=self.file_ship, size=(self.width_ship, self.height_ship), allow_stretch=True) self.add_widget(self._ship) self._ship.add_widget(self._img_ship) self.bind(pos=self._update) self.bind(size=self._update) self.bind(value=self._aniSweep)
def prod_menu(build_place): scatter = ScatterLayout() menu = MenuLayout() inside_menu = InsideMenuLayout() main_box = BoxLayout(orientation='horizontal') left_box = BoxLayout(orientation='vertical', size_hint_x=.35) right_box = BoxLayout(size_hint_x=.65) icon_bottom_box = BoxLayout(size_hint=(.9, .8)) icon_layout = BoxLayout(size_hint_y=.4) # pos_hint=({'top': 1}) statistic_grid = GridLayout(cols=1, size_hint_y=None, pos_hint=({ 'top': .9 }), spacing=10, padding=5) for r in config.resources: res = config.resources[r] stat_box = BoxLayout(orientation='horizontal', height=40, size_hint_y=None) stat_box.add_widget(Image(source=res[2], size_hint_x=.2)) stat_box.add_widget(Label(text=f'{res[0]}', size_hint_x=.8)) statistic_grid.add_widget(stat_box) tb = TabbedPanel(do_default_tab=False, tab_width=130) ti = TabbedPanelItem(text='Улучшения') ti.content = prod_upgrade_content() tb.add_widget(ti) tb.add_widget(TabbedPanelItem(text='Автоматизация')) tb.add_widget(TabbedPanelItem(text='Статистика')) icon_bottom_box.add_widget(statistic_grid) icon_layout.add_widget(Image(source='data/images/buildings/buildings.zip')) left_box.add_widget(icon_layout) left_box.add_widget(icon_bottom_box) right_box.add_widget(tb) main_box.add_widget(left_box) main_box.add_widget(right_box) inside_menu.add_widget(main_box) close_b = CloseMenuButton(build_place, scatter) menu.add_widget(inside_menu) menu.add_widget(close_b) scatter.add_widget(menu) return scatter
def gen_set(self): scatter = ScatterLayout() menu = building.MenuLayout() inside_menu = building.InsideMenuLayout() main_box = BoxLayout(orientation='horizontal') left_box = BoxLayout(orientation='vertical', size_hint_x=.35) right_box = BoxLayout(size_hint_x=.65) icon_bottom_box = BoxLayout(size_hint=(.9, .8)) icon_layout = BoxLayout(size_hint_y=.4) # pos_hint=({'top': 1}) left_box.add_widget(icon_layout) left_box.add_widget(icon_bottom_box) main_box.add_widget(left_box) main_box.add_widget(right_box) inside_menu.add_widget(main_box) close_b = building.CloseMenuButton(self, scatter) menu.add_widget(inside_menu) menu.add_widget(close_b) scatter.add_widget(menu) return scatter
def __init__(self, **kwargs): super(hitBang, self).__init__(**kwargs) self.animation = Clock.create_trigger(self.animateHit, 0.25) self.cur_pos = (0.0, 0.0) self.ani = 0 self._shot = ScatterLayout(size=(self.width_shot, self.height_shot), do_rotate=False, do_scale=False, do_translation=False) _img_shot = Image(source=self.file_pin, size=(self.width_shot, self.height_shot), allow_stretch=True) self._shot.add_widget(_img_shot) self.add_widget(self._shot) self.bind(pos=self._update) self.bind(size=self._update)
def open_terminal(self): scatter_terminal = ScatterLayout(size_hint=(.4, .5)) terminal_lay = TerminalRelativeLayout() scroll_terminal = TerminalScrollView(size_hint=(.97, .87), pos_hint=({'center_x': .5, 'top': .9})) terminal_top = RelativeLayout(size_hint=(.97, .1), pos_hint=({'center_x': .5, 'top': 1})) terminal_top.add_widget(TerminalIcon(pos_hint=({'x': .005, 'top': 1}), size_hint_x=.04)) terminal_top.add_widget(TerminalTitleLabel(text=r'C:\JARVIS\Terminal [Version 7.1.2336]', pos_hint=({'x': .05, 'top': 1}), size_hint_x=.992)) terminal_top.add_widget( TerminalClose(parent_lay=self.layout, close_lay=scatter_terminal, pos_hint=({'right': .99, 'top': 1}), size_hint_x=.04)) terminal_main = TerminalGridLayout(cols=1, size_hint_y=None, padding=3, spacing=5) terminal_main.bind(minimum_height=terminal_main.setter('height')) terminal_main.add_widget( TerminalLabel(text='JARVIS Terminal (c) Corporation JARVIS, 2044. All rights reserved')) terminal_main.add_widget(TerminalTextInput(grid=terminal_main)) terminal_lay.add_widget(terminal_top) scroll_terminal.add_widget(terminal_main) terminal_lay.add_widget(scroll_terminal) scatter_terminal.add_widget(terminal_lay) self.layout.add_widget(scatter_terminal)
def base_window(build_place): # Шаблон для окна scatter = ScatterLayout() menu = MenuLayout() inside_menu = InsideMenuLayout() main_box = BoxLayout(orientation='horizontal', minimum_size=(700, 400)) left_box = BoxLayout(orientation='vertical', size_hint_x=.3) right_box = BoxLayout(size_hint_x=.7) bottom_box = BoxLayout(size_hint=(.95, .8)) icon_box = FrameBoxLayout(orientation='vertical', size_hint_y=.4) statistic_grid = GridLayout(cols=1, spacing=10, padding=5) icon_box.add_widget(Image(source=config.empty_icon)) left_box.add_widget(icon_box) bottom_box.add_widget(statistic_grid) left_box.add_widget(bottom_box) main_box.add_widget(left_box) main_box.add_widget(right_box) inside_menu.add_widget(main_box) close_b = CloseMenuButton(build_place, scatter) menu.add_widget(inside_menu) menu.add_widget(close_b) scatter.add_widget(menu) return scatter, icon_box, statistic_grid, right_box
def menu_content(build_place): tb = TabbedPanel(do_default_tab=False, tab_width=150) tab_all = TabbedPanelHeader(text='Все') tab_war = TabbedPanelHeader(text='Военные') tab_prod = TabbedPanelItem(text='Производственные') tab_social = TabbedPanelHeader(text='Социальные') scatter = ScatterLayout(id='scatter_layout') # size_hint_max=(1000, 800) name_label = PlaceLabel(text=f'Место для строительства: {build_place.id}') menu = MenuLayout() inside_menu = InsideMenuLayout() tb.add_widget(tab_all) tb.add_widget(tab_war) tb.add_widget(tab_social) tb.add_widget(tab_prod) for tab in tb.tab_list: tab.content = create_building_list(tab.text, build_place, scatter) inside_menu.add_widget(tb) menu.add_widget(inside_menu) menu.add_widget(name_label) close_b = CloseMenuButton(build_place, scatter) menu.add_widget(close_b) scatter.add_widget(menu) return scatter
def __init__(self, **kwargs): # 父类构造方法 super().__init__(**kwargs) # 设置背景颜色(可忽略) with self.canvas: # 背景颜色 Color(1, 1, 1, 1) # 浮动布局矩形 = 矩形(位置=布局位置,大小=布局大小) self.rect = Rectangle(pos=self.pos, size=self.size) # 浮动布局绑定(位置=布局矩形位置,大小=设置背景尺寸) self.bind(pos=self.update_rect, size=self.update_rect) # 缩放布局 scatter_layout = ScatterLayout() # 异步图片 image = AsyncImage(source='http://sck.rjkflm.com/images/logo1.png') # 布局加组件(异步图片) scatter_layout.add_widget(image) # 布局加组件(缩放布局) self.add_widget(scatter_layout)
def pressed(self, instance): top3_rank = final_combiner.final_rank([ int(self.left.two.input1.text), int(self.left.two.input3.text), int(self.left.two.input5.text) ], self.spinner.text) print("實際的前三名:", end="") print(top3_rank) if not self.acard: self.rank1 = ThreeLineIconListItem( text=top3_rank[0][0].split('區')[1], secondary_text='人口特性:' + str(top3_rank[0][1]), tertiary_text='新資所得:' + str(top3_rank[0][2]), text_color=[1, 1, 1, 1]) self.rank1.add_widget(IconLeftWidget(icon='numeric-1-box')) self.rank1.bg_color = [0, 0, 0, 0] self.rank1.children[1].children[2].font_name = 'msjhbd.ttc' self.rank1.children[1].children[1].font_name = 'msjhbd.ttc' self.rank1.children[1].children[0].font_name = 'msjhbd.ttc' self.rank1.children[1].children[2].font_size = '18' more_rank1 = MDLabel(text='人口消長:' + str(top3_rank[0][3])) more_rank1.font_name = 'msjhbd.ttc' more_rank1.font_style = 'Body1' more_rank1.font_size = 16 more_rank1.color = [0, 0, 0, 0.7] self.rank1.children[1].add_widget(more_rank1) self.rank1.children[1].size_hint = [1, None] self.rank1.children[1].children[3].pos = [56, 280] self.rank1.children[0].children[0].children[0].color = [1, 1, 1, 1] self.rank1.children[0].children[0].children[0].pos_hint = { 'left': 0.1 } self.rank1.children[0].padding = [-10, 0, 0, 0] self.rank1.children[1].children[3].theme_text_color = 'Custom' self.rank1.children[1].children[3].text_color = [1, 1, 1, 1] self.rank1.children[1].children[2].theme_text_color = 'Custom' self.rank1.children[1].children[2].text_color = [1, 1, 1, 1] self.rank1.children[1].children[1].theme_text_color = 'Custom' self.rank1.children[1].children[1].text_color = [1, 1, 1, 1] self.rank1.children[1].children[0].theme_text_color = 'Custom' self.rank1.children[1].children[0].text_color = [1, 1, 1, 1] self.rank1.children[1].height = 110 # 從另一個預先寫好、計算各里指標分數的模組final_combiner引進final_rank函數,取得前三名的區域及其各項指標分數後用top3_rank變數紀錄起來 # 接著改寫、擴充kivy套件內的工具(ThreeLineIconListItem),做成資訊卡,同時使其擁有按鈕的特性讓使用者做點選 self.rank2 = ThreeLineIconListItem( text=top3_rank[1][0].split('區')[1], secondary_text='人口特性:' + str(top3_rank[1][1]), tertiary_text='新資所得:' + str(top3_rank[1][2])) self.rank2.add_widget(IconLeftWidget(icon='numeric-2-box')) self.rank2.bg_color = [0, 0, 0, 0] self.rank2.children[1].children[2].font_size = '18' self.rank2.children[1].children[2].font_name = 'msjhbd.ttc' self.rank2.children[1].children[1].font_name = 'msjhbd.ttc' self.rank2.children[1].children[0].font_name = 'msjhbd.ttc' more_rank2 = MDLabel(text='人口消長:' + str(top3_rank[1][3])) more_rank2.font_name = 'msjhbd.ttc' more_rank2.font_style = 'Body1' more_rank2.font_size = 16 more_rank2.color = [0, 0, 0, 0.54] self.rank2.children[1].add_widget(more_rank2) self.rank2.children[1].size_hint = [1, None] self.rank2.children[0].children[0].children[0].color = [1, 1, 1, 1] self.rank2.children[0].children[0].children[0].pos_hint = { 'left': 0.1 } self.rank2.children[0].padding = [-10, 0, 0, 0] self.rank2.children[1].children[3].theme_text_color = 'Custom' self.rank2.children[1].children[3].text_color = [1, 1, 1, 1] self.rank2.children[1].children[2].theme_text_color = 'Custom' self.rank2.children[1].children[2].text_color = [1, 1, 1, 1] self.rank2.children[1].children[1].theme_text_color = 'Custom' self.rank2.children[1].children[1].text_color = [1, 1, 1, 1] self.rank2.children[1].children[0].theme_text_color = 'Custom' self.rank2.children[1].children[0].text_color = [1, 1, 1, 1] self.rank3 = ThreeLineIconListItem( text=top3_rank[2][0].split('區')[1], secondary_text='人口特性:' + str(top3_rank[2][1]), tertiary_text='新資所得:' + str(top3_rank[2][2])) self.rank3.add_widget(IconLeftWidget(icon='numeric-3-box')) self.rank3.bg_color = [0, 0, 0, 0] self.rank3.children[1].children[2].font_size = '18' self.rank3.children[1].children[2].font_name = 'msjhbd.ttc' self.rank3.children[1].children[1].font_name = 'msjhbd.ttc' self.rank3.children[1].children[0].font_name = 'msjhbd.ttc' more_rank3 = MDLabel(text='人口消長:' + str(top3_rank[2][3])) more_rank3.font_name = 'msjhbd.ttc' more_rank3.font_style = 'Body1' more_rank3.font_size = 16 more_rank3.color = [0, 0, 0, 0.54] self.rank3.children[1].add_widget(more_rank3) self.rank3.children[1].size_hint = [1, None] self.rank3.children[0].children[0].children[0].color = [1, 1, 1, 1] self.rank3.children[0].children[0].children[0].pos_hint = { 'left': 0.1 } self.rank3.children[0].padding = [-10, 0, 0, 0] self.rank3.children[1].children[3].theme_text_color = 'Custom' self.rank3.children[1].children[3].text_color = [1, 1, 1, 1] self.rank3.children[1].children[2].theme_text_color = 'Custom' self.rank3.children[1].children[2].text_color = [1, 1, 1, 1] self.rank3.children[1].children[1].theme_text_color = 'Custom' self.rank3.children[1].children[1].text_color = [1, 1, 1, 1] self.rank3.children[1].children[0].theme_text_color = 'Custom' self.rank3.children[1].children[0].text_color = [1, 1, 1, 1] self.rank1.size = [352, 100] self.rank2.size = [352, 100] self.rank3.size = [352, 100] self.click += 1 self.rank1.children[1].padding = [56, 16, 24, 7] self.rank2.children[1].padding = [56, 4, 24, 7] self.rank3.children[1].padding = [56, 4, 24, 7] self.rank1.children[1].children[0].adaptive_height = True self.rank1.children[1].pos = [0, 180] self.rank2.children[1].children[1].adaptive_height = True self.rank2.children[1].pos = [0, 130] self.rank3.children[1].children[1].adaptive_height = True self.lll = ScatterLayout(size_hint=[0.2, 0.6]) self.myLast = MDGridLayout(cols=1, size_hint=[0.8, 0.85], md_bg_color=[0.39, 0.4, 0.8, 0.8]) self.myLast.add_widget(self.rank1) # 0.285,0.5 self.myLast.add_widget(self.rank2) self.myLast.add_widget(self.rank3) self.lll.add_widget(self.myLast) from kivy.core.window import Window Window.add_widget(self.lll) self.lll.center = (640, 328) self.rank1.bind(on_release=self.add_renk1_marker) self.rank2.bind(on_release=self.add_renk2_marker) self.rank3.bind(on_release=self.add_renk3_marker) lat = 0 lon = 0 try: with open(os.path.realpath(sys.argv[0]).strip(sys.argv[0]) + 'district.json', 'r', encoding='utf-8') as q: q = json.load(q) lat = q["臺中市" + self.spinner.text][0][0] lon = q["臺中市" + self.spinner.text][0][1] except: print(self.spinner.text + "經緯度有問題") self.map.zoom = 12 self.map.center_on(float(lat), float(lon))
def build(self): scatter = ScatterLayout() label = Label(text='hello, world', font_size=60) scatter.add_widget(label) return scatter
def build(self): sl = ScatterLayout() al = AnchorLayout() bl = BoxLayout(orientation='vertical', padding=[.05, .05], spacing=2) bl1 = BoxLayout(orientation='horizontal', spacing=0) bl2 = BoxLayout(orientation='horizontal', spacing=0) bl3 = BoxLayout(orientation='horizontal', spacing=0) bl4 = BoxLayout(orientation='horizontal', spacing=0) bl5 = BoxLayout(orientation='horizontal', spacing=0) bl6 = BoxLayout(orientation='horizontal', spacing=0) bl7 = BoxLayout(orientation='horizontal', spacing=0) bl8 = BoxLayout(orientation='horizontal', spacing=0) bl9 = BoxLayout(orientation='horizontal', spacing=0, size_hint=(1, .5), padding=[0]) self.lab1 = Label(text='Зона №1') self.lab1.bind(size=self._update_rect1, pos=self._update_rect1) with self.lab1.canvas.before: Color(0, 43, 230, 255) self.rect1 = Rectangle(size=self.lab1.size, pos=self.lab1.pos) self.bt1 = Button(text='Вкл', size_hint=(.2, 1)) self.bt1.bind(on_press=self.pressing1) self.lab2 = Label(text='Зона №2') self.lab2.bind(size=self._update_rect2, pos=self._update_rect2) with self.lab2.canvas.before: Color(0, 43, 230, 255) # green; colors range from 0-1 not 0-255 self.rect2 = Rectangle(size=self.lab2.size, pos=self.lab2.pos) self.bt2 = Button(text='Вкл', size_hint=(.2, 1)) self.bt2.bind(on_press=self.pressing2) self.lab3 = Label(text='Зона №3') self.lab3.bind(size=self._update_rect3, pos=self._update_rect3) with self.lab3.canvas.before: Color(0, 43, 230, 255) # green; colors range from 0-1 not 0-255 self.rect3 = Rectangle(size=self.lab3.size, pos=self.lab3.pos) self.bt3 = Button(text='Вкл', size_hint=(.2, 1)) self.bt3.bind(on_press=self.pressing3) self.lab4 = Label(text='Зона №4') self.lab4.bind(size=self._update_rect4, pos=self._update_rect4) with self.lab4.canvas.before: Color(0, 43, 230, 255) # green; colors range from 0-1 not 0-255 self.rect4 = Rectangle(size=self.lab4.size, pos=self.lab4.pos) self.bt4 = Button(text='Вкл', size_hint=(.2, 1)) self.bt4.bind(on_press=self.pressing4) self.lab5 = Label(text='Зона №5') self.lab5.bind(size=self._update_rect5, pos=self._update_rect5) with self.lab5.canvas.before: Color(0, 43, 230, 255) # green; colors range from 0-1 not 0-255 self.rect5 = Rectangle(size=self.lab5.size, pos=self.lab5.pos) self.bt5 = Button(text='Вкл', size_hint=(.2, 1)) self.bt5.bind(on_press=self.pressing5) self.lab6 = Label(text='Зона №6') self.lab6.bind(size=self._update_rect6, pos=self._update_rect6) with self.lab6.canvas.before: Color(0, 43, 230, 255) # green; colors range from 0-1 not 0-255 self.rect6 = Rectangle(size=self.lab6.size, pos=self.lab6.pos) self.bt6 = Button(text='Вкл', size_hint=(.2, 1)) self.bt6.bind(on_press=self.pressing6) self.lab7 = Label(text='Зона №7') self.lab7.bind(size=self._update_rect7, pos=self._update_rect7) with self.lab7.canvas.before: Color(0, 43, 230, 255) # green; colors range from 0-1 not 0-255 self.rect7 = Rectangle(size=self.lab7.size, pos=self.lab7.pos) self.bt7 = Button(text='Вкл', size_hint=(.2, 1)) self.bt7.bind(on_press=self.pressing7) self.lab8 = Label(text='Зона №8') self.lab8.bind(size=self._update_rect8, pos=self._update_rect8) with self.lab8.canvas.before: Color(0, 43, 230, 255) # green; colors range from 0-1 not 0-255 self.rect8 = Rectangle(size=self.lab8.size, pos=self.lab8.pos) self.bt8 = Button(text='Вкл', size_hint=(.2, 1)) self.bt8.bind(on_press=self.pressing8) self.lab9 = Label() self.bt9 = Button(text='Подключиться', size_hint=(1, 1)) self.bt9.bind(on_press=self.pressing9) self.lab10 = Label() sl.add_widget(al) al.add_widget(bl) bl.add_widget(bl1) bl1.add_widget(self.lab1) bl1.add_widget(self.bt1) bl.add_widget(bl2) bl2.add_widget(self.lab2) bl2.add_widget(self.bt2) bl.add_widget(bl3) bl3.add_widget(self.lab3) bl3.add_widget(self.bt3) bl.add_widget(bl4) bl4.add_widget(self.lab4) bl4.add_widget(self.bt4) bl.add_widget(bl5) bl5.add_widget(self.lab5) bl5.add_widget(self.bt5) bl.add_widget(bl6) bl6.add_widget(self.lab6) bl6.add_widget(self.bt6) bl.add_widget(bl7) bl7.add_widget(self.lab7) bl7.add_widget(self.bt7) bl.add_widget(bl8) bl8.add_widget(self.lab8) bl8.add_widget(self.bt8) bl.add_widget(bl9) bl9.add_widget(self.lab9) bl9.add_widget(self.bt9) bl9.add_widget(self.lab10) self.data1 = '0' self.data2 = '0' self.data3 = '0' self.data4 = '0' self.data5 = '0' self.data6 = '0' self.data7 = '0' self.data8 = '0' return sl
def __init__(self, **kwargs): self.scatterlayout = ScatterLayout(do_rotation=False, do_translation_y=False) super(LatexWidget, self).__init__(**kwargs) self.add_widget(self.scatterlayout)
def play_solid_scene(self, data, *args): # print " " # print "BUILDING SCENE", data # print " " if platform == 'ios' or platform == 'android': self.app.appix_base.clear_all_labels() self.app.appix_base.event_manager.sports_manager.stop_sports_scene() else: try: self.window_width = self.app.main_stage.ids["content_stencil"].width self.window_height = self.app.main_stage.ids["content_stencil"].height except AttributeError: pass # print "BPM ----------> ", self.bpm # if platform == 'ios' or platform == 'android': # self.app.appix_base.clear_all_labels() self.scene_playing = True # Needed for labels on phone scene_num = int(data['scene_num']) if self.layers[scene_num]: self.stop_solid_scene(data) element_layout = ScatterLayout(do_rotation=False, do_translation=False, do_scale=False) element_layout.auto_bring_to_front = False element_layout.width = self.window_width # * element_settings['size_x'] element_layout.height = self.window_height # * element_settings['size_y'] self.layers[scene_num] = element_layout gradient_cycles, blink_cycles, full_duration = self.calculate_loop_extensions(data) if len(data["color_ids"]) == 1: color = self.rendered_color(data["color_ids"][0]) color_key_frames = [KeyFrame(at=0, rgba=color), KeyFrame(at=full_duration, rgba=color)] else: original_color_length = len(data["color_ids"]) color_key_frames = self.build_gradient_parameters(data, original_color_length, gradient_cycles, full_duration) if data["blink_speed"]: blink_key_frames, blink_random_offset = self.build_blink_parameters(data, blink_cycles) else: blink_key_frames = [KeyFrame(at=0, opacity=1), KeyFrame(at=full_duration, opacity=1)] blink_random_offset = 0 # TODO: END BLINK CODE HERE track = (ColorTrack( RectangleTrack( KeyFrame(at=0., pos=Expr("widget.pos"), size=Expr("widget.size")), KeyFrame(at=full_duration, pos=Expr("widget.x, widget.y")), canvas="before" ), *color_key_frames, canvas="before" ), RelativeAttributeTrack( *blink_key_frames ), ) # Offset the start time # TODO: this will also offset the start of the gradients animation - probably don't want this? # Clock.schedule_once(partial(self.start_animation, track, scene_num), blink_random_offset) self.start_animation(track, scene_num)
def building_content(self, build_place, build): building = config.buildings[build] scatter = ScatterLayout(id='town_hall_scatter') name_label = PlaceLabel(text=f'{build}, id: {build_place.id}') menu = MenuLayout() inside_menu = InsideMenuLayout() top_layout = BoxLayout(orientation='horizontal', size_hint_y=.3) bottom_layout = BoxLayout(orientation='vertical', size_hint_y=.3) right_layout = BoxLayout(orientation='vertical') upgrade_layout = BoxLayout(orientation='horizontal', size_hint_y=.3) description_layout = BoxLayout(size_hint_y=.7) description_label = Label(text='Описание здания') description_layout.add_widget(description_label) icon_rel = BoxLayout(size_hint_x=.3) icon = Image(source=building[3]) icon_rel.add_widget(icon) upgrade_label = Label(text=f'{building[1]} сек', size_hint_x=.9) upgrade_res_layout = BoxLayout(orientation='horizontal') for i, res_cost in enumerate(building[2]): if res_cost > 0: res_box = BoxLayout(orientation='horizontal', size_hint_x=.5) help_lay_res = RelativeLayout() help_lay_res.add_widget( Image(source=f'{config.resources[res_list[i]][2]}', size=(25, 25), pos_hint=({ 'right': 1 }), size_hint=(None, 1))) add_lay = GridLayout(cols=2, size_hint=(1, 1), pos_hint=({ 'center_x': .5, 'center_y': .5 })) add_lay.add_widget(help_lay_res) add_lay.add_widget(BuildResLabel(text=f'{res_cost}')) res_box.add_widget(add_lay) upgrade_res_layout.add_widget(res_box) upgrade_button = Button(text='Up', size_hint_x=.1) upgrade_layout.add_widget(upgrade_button) upgrade_layout.add_widget(upgrade_label) upgrade_layout.add_widget(upgrade_res_layout) right_layout.add_widget(upgrade_layout) right_layout.add_widget(description_layout) top_layout.add_widget(icon_rel) top_layout.add_widget(right_layout) middle_lay = BoxLayout(size_hint_y=.4) slider_layout = BoxLayout(orientation='vertical', size_hint_y=.7) input_layout = BoxLayout(orientation='horizontal', size_hint=(.3, 1), pos_hint=({ 'right': 1 })) text_input = UnitTextInput(text='0', size_hint_y=.9, pos_hint=({ 'center_y': .5 }), multiline=False) total_res_layout = BoxLayout(orientation='horizontal', size_hint_x=.65, padding=5) self.slider = UnitSlider(text_input, size_hint_y=.55, padding=10) total_inside = TotalInsideLayout(orientation='horizontal', slider=self.slider) time_label = TotalTimeLabel(size_hint_y=.3, halign='left') total_res_label = TotalResLabel(text='Стоимость:', size_hint_x=.35) text_input.slider = self.slider self.slider.total_inside = total_inside self.slider.time_label = time_label self.slider.total_res_label = total_res_label hire_button = HireUnitsButton(text='Нанять', disabled=True, slider=self.slider, build_root=self) count_box = BoxLayout(orientation='vertical', size_hint_x=.25, padding=1, spacing=1) up_button = UpButton(opacity=0, slider=self.slider) down_button = DownButton(opacity=0, slider=self.slider) bottom_slider_lay = BoxLayout(orientation='horizontal', size_hint_y=.45) scroll_unit = ScrollView(do_scroll_x=False, scroll_distance=50, size_hint_y=.8, pos_hint=({ 'center_y': .5 })) butt_list = [up_button, down_button] self.unit_grid = GridLayout(cols=1, padding=5, spacing=5, size_hint_y=None, opacity=0) self.unit_grid.bind(minimum_height=self.unit_grid.setter('height')) self.available_list = [] checkbox_group_list = [] for unit_name in building[5]: unit = config.units[unit_name] checkbox = UnitCheckBox(group='units', size_hint_x=.05, slider=self.slider, txt_inp=text_input, unit=unit_name, hb=hire_button, bl=butt_list, trl=total_res_label, tl=time_label) checkbox.bind(active=on_checkbox_active) checkbox_group_list.append(checkbox) grid_layout = UnitGridLayout(cols=6, size_hint_y=None, height=40, checkbox=checkbox) unit_icon = Image(source=unit[3], size_hint_x=.05) unit_name_label = Label(text=f'{unit_name}', size_hint_x=.2) unit_cost = BoxLayout(orientation='horizontal', size_hint_x=.45) for i, res_cost in enumerate(unit[2]): if res_cost > 0: res_box = BoxLayout(orientation='horizontal', size_hint_x=.5) help_lay_res = RelativeLayout() help_lay_res.add_widget( Image(source=f'{config.resources[res_list[i]][2]}', size=(25, 25), pos_hint=({ 'right': 1 }), size_hint=(None, 1))) add_lay = GridLayout(cols=2, size_hint=(1, 1), pos_hint=({ 'center_x': .5, 'center_y': .5 })) add_lay.add_widget(help_lay_res) add_lay.add_widget(BuildResLabel(text=f'{res_cost}')) res_box.add_widget(add_lay) unit_cost.add_widget(res_box) unit_time = Label(text=f'{unit[1]} сек', size_hint_x=.15) how_many_lay = BoxLayout(orientation='horizontal', size_hint_x=.1) available_label = Label(text='8', size_hint_y=.8, pos_hint=({ 'center_y': .5 })) checkbox.available_label = available_label self.available_list.append(available_label) all_button = AllUnitButton(text='All', size_hint_y=.6, pos_hint=({ 'center_y': .5 }), checkbox=checkbox) how_many_lay.add_widget(all_button) how_many_lay.add_widget(available_label) grid_layout.add_widget(checkbox) grid_layout.add_widget(unit_icon) grid_layout.add_widget(unit_name_label) grid_layout.add_widget(unit_cost) grid_layout.add_widget(unit_time) grid_layout.add_widget(how_many_lay) self.unit_grid.add_widget(grid_layout) self.slider.group_list = checkbox_group_list scroll_unit.add_widget(self.unit_grid) count_box.add_widget(up_button) count_box.add_widget(down_button) input_layout.add_widget(count_box) input_layout.add_widget(text_input) input_layout.add_widget(hire_button) slider_layout.add_widget(self.slider) total_res_layout.add_widget(total_res_label) total_res_layout.add_widget(total_inside) bottom_slider_lay.add_widget(total_res_layout) bottom_slider_lay.add_widget(input_layout) slider_layout.add_widget(bottom_slider_lay) middle_lay.add_widget(scroll_unit) bottom_layout.add_widget(slider_layout) bottom_layout.add_widget(time_label) inside_menu.add_widget(top_layout) inside_menu.add_widget(middle_lay) inside_menu.add_widget(bottom_layout) menu.add_widget(inside_menu) menu.add_widget(name_label) close_b = CloseMenuButton(self, scatter) menu.add_widget(close_b) scatter.add_widget(menu) self.update_available_units() anim_opacity_up.start(self.unit_grid) return scatter
def __init__(self, **kwargs): super(Application, self).__init__(**kwargs) Clock.schedule_interval(self.update, 0) self.time = 0 self.packetLength = 46080 #Packet length determined for 20 packets containing 640x480 pixel frame self.sumData = [] self.bimage = b'' #Byte variables used for frame operations self.transfer = b'' self.texData = b'' self.tmp = b'' self.threads = [] #Used for threading self.image = "" #IP adress container self.ip = [ TextInput(multiline=False, font_size=12), TextInput(multiline=False, font_size=12), TextInput(multiline=False, font_size=12), TextInput(multiline=False, font_size=12) ] self.port = TextInput(multiline=False, font_size=12) #Port container self.password = TextInput(multiline=False, password=True, font_size=12) #Password container self.UDP_IP_ADDRESS = "192.168.56.1" self.UDP_PORT_NO = 6789 self.Message = "ip: " + self.ip[0].text + "." + self.ip[ 1].text + "." + self.ip[2].text + "." + self.ip[ 3].text + " port: " + self.port.text self.clientSock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM) #Socket initialization self.clientSock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 921600) #Socket options self.popupWindow = Popup(title="Enter ip, port and password to access." ) #Popup window initialization self.cols = 1 self.texture = Texture.create( size=(640, 480), colorfmt='rgb') #Texture for camera frames initalization self.texture.flip_vertical() self.data = b'\xff\x00\x00' * 320 * 480 + (b'\x00\xff\x00' * 320 * 480) self.texture.blit_buffer(self.data, colorfmt='bgr') self.img = Image(size=self.texture.size, texture=self.texture) self.cent = ScatterLayout( do_rotation=False, do_scale=False, do_translation_y=False, do_translation_x=False, ) self.add_widget(self.cent) self.cent.rotation = 90 self.cent.add_widget(self.img) self.buttonsLay = GridLayout() self.buttonsLay.cols = 3 #3x4 buttons grid setup self.add_widget(self.buttonsLay) self.BtnTL = Button(background_normal="arrowUL.png", background_down="arrowULNeg.png", pos_hint={ "x": 0.3, "top": 0.3 }) self.BtnTL.bind(on_release=partial(self.BTN, message="TL")) self.buttonsLay.add_widget(self.BtnTL) self.BtnT = Button(background_normal="arrowUp.png", background_down="arrowUpNeg.png", pos_hint={ "x": 0.3, "top": 0.3 }) self.BtnT.bind(on_release=partial(self.BTN, message="TM")) self.buttonsLay.add_widget(self.BtnT) self.BtnTR = Button(background_normal="arrowUR.png", background_down="arrowURNeg.png", pos_hint={ "x": 0.3, "top": 0.3 }) self.BtnTR.bind(on_release=partial(self.BTN, message="TR")) self.buttonsLay.add_widget(self.BtnTR) self.BtnL = Button(background_normal="arrowLeft.png", background_down="arrowLeftNeg.png", pos_hint={ "x": 0.3, "top": 0.3 }) self.BtnL.bind(on_release=partial(self.BTN, message="ML")) self.buttonsLay.add_widget(self.BtnL) self.Btn = Button(background_normal="arrowMiddle.png", background_down="arrowMiddleNeg.png", pos_hint={ "x": 0.3, "top": 0.3 }) self.Btn.bind(on_release=partial(self.BTN, message="MM")) self.buttonsLay.add_widget(self.Btn) self.BtnR = Button(background_normal="arrowRight.png", background_down="arrowRightNeg.png", pos_hint={ "x": 0.3, "top": 0.3 }) self.BtnR.bind(on_release=partial(self.BTN, message="MR")) self.buttonsLay.add_widget(self.BtnR) self.BtnBL = Button(background_normal="arrowDL.png", background_down="arrowDLNeg.png", pos_hint={ "x": 0.3, "top": 0.3 }) self.BtnBL.bind(on_release=partial(self.BTN, message="BL")) self.buttonsLay.add_widget(self.BtnBL) self.BtnB = Button(background_normal="arrowDown.png", background_down="arrowDownNeg.png", pos_hint={ "x": 0.3, "top": 0.3 }) self.BtnB.bind(on_release=partial(self.BTN, message="BM")) self.buttonsLay.add_widget(self.BtnB) self.BtnBR = Button(background_normal="arrowDR.png", background_down="arrowDRNeg.png", pos_hint={ "x": 0.3, "top": 0.3 }) self.BtnBR.bind(on_release=partial(self.BTN, message="BR")) self.buttonsLay.add_widget(self.BtnBR) self.popupBtn = Button(background_normal="connect.png", background_down="connectNeg.png", pos_hint={ "x": 0.3, "top": 0.3 }) self.popupBtn.bind(on_release=self.showPopup) self.buttonsLay.add_widget(self.popupBtn) self.popupBtn = Button(background_normal="screenshot.png", background_down="screenshotNeg.png", pos_hint={ "x": 0.3, "top": 0.3 }) self.popupBtn.bind(on_release=self.frameShot) self.buttonsLay.add_widget(self.popupBtn) self.popupBtn = Button(background_normal="rec.png", background_down="recNeg.png", pos_hint={ "x": 0.3, "top": 0.3 }) self.popupBtn.bind(on_release=partial(self.BTN, message="MM")) self.buttonsLay.add_widget(self.popupBtn) self.initPopup(self)