Beispiel #1
0
    def __init__(self):
        global _datasource

        self.name = 'Drag & Drop'

        self.width = min(ui.get_window_size()[0] * 0.8, 700)
        self.height = ui.get_window_size()[1] * 0.8

        path = editor.get_path()
        if path:
            expanded_folder = os.path.dirname(path)
            files = tab.get_paths()
        else:
            expanded_folder = None
            files = None

        root_node = FileNode(os.path.expanduser('~/Documents'), ignore=ignore)
        _datasource = FolderPickerDataSource(root_node, expanded_folder, files)

        tv = ui.TableView(frame=self.bounds, flex='WH')
        tv.delegate = _datasource
        tv.data_source = _datasource
        tv.allows_multiple_selection = False
        tv.allows_selection = True
        tv.allows_multiple_selection_during_editing = False
        tv.allows_selection_during_editing = False
        tv.separator_color = 'clear'
        self.add_subview(tv)

        methods = [tableView_itemsForBeginningDragSession_atIndexPath_]
        protocols = ['UITableViewDragDelegate']
        DragDelegate = create_objc_class('DragDelegate',
                                         methods=methods,
                                         protocols=protocols)
        self._drag_delegate = DragDelegate.alloc().init()

        methods = [
            tableView_canHandleDropSession_,
            tableView_dropSessionDidUpdate_withDestinationIndexPath_,
            tableView_performDropWithCoordinator_
        ]
        protocols = ['UITableViewDropDelegate']
        DropDelegate = create_objc_class('DropDelegate',
                                         methods=methods,
                                         protocols=protocols)
        self._drop_delegate = DropDelegate.alloc().init()

        tv_objc = ObjCInstance(tv)
        tv_objc.setDragDelegate_(self._drag_delegate)
        tv_objc.setDropDelegate_(self._drop_delegate)

        def handle_escape():
            self.close()

        self._handlers = [
            register_key_event_handler(UIEventKeyCode.ESCAPE, handle_escape),
            register_key_event_handler(UIEventKeyCode.DOT,
                                       handle_escape,
                                       modifier=UIKeyModifier.COMMAND)
        ]
Beispiel #2
0
    def init(self):
        self.main = load_view('mainmenu.pyui')
        self.lanui = load_view('lan.pyui')
        self.game = SceneView()
        self.game.shows_fps = True
        self.game.frame = (0, 0, get_window_size()[0], get_window_size()[1])

        self.main['worlds'].data_source.items = listdir('saves')

        self.add_subview(self.main)
Beispiel #3
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        if 'background_color' not in kwargs:
            self.background_color = 'white'

        if 'frame' not in kwargs:
            self.width = min(ui.get_window_size()[0] * 0.8, 700)
            self.height = ui.get_window_size()[1] * 0.8

        self._tableview = ui.TableView()
        self._textfield = ui.TextField()
        self._help_label = ui.Label()
        self._datasource = None
        self._handlers = None
        self.shift_enter_enabled = True
        self.did_select_item_action = None

        tf = LayoutProxy(self._textfield)
        self.add_subview(tf)
        tf.layout.align_left_with_superview.equal = 8
        tf.layout.align_top_with_superview.equal = 8
        tf.layout.align_right_with_superview.equal = -8
        tf.layout.height.equal = 31
        tf.delegate = self

        tv = LayoutProxy(self._tableview)
        self.add_subview(tv)
        tv.layout.align_left_to(tf).equal = 0
        tv.layout.align_right_to(tf).equal = 0
        tv.layout.top_offset_to(tf).equal = 8
        tv.allows_selection = True
        tv.allows_multiple_selection = False

        hl = LayoutProxy(self._help_label)
        self.add_subview(hl)
        hl.layout.align_left_to(tv).equal = 0
        hl.layout.align_right_to(tv).equal = 0
        hl.layout.top_offset_to(tv).equal = 8
        hl.layout.align_bottom_with_superview.equal = -8
        hl.layout.height.max = 66
        hl.font = ('<system>', 13.0)
        hl.alignment = ui.ALIGN_CENTER
        hl.text_color = (0, 0, 0, 0.5)
        hl.number_of_lines = 2

        if is_in_hardware_keyboard_mode:
            tf.view.begin_editing()

        self._register_key_event_handlers()
Beispiel #4
0
    def __init__(self, rootpath, test_mod=0):
        self.name = 'AppWishList'
        self.rootpath = rootpath
        self.appService = AppService(rootpath)
        self.configService = ConfigService(rootpath)

        self.isUpdating = False
        self.orientation = self.LANDSCAPE
        self.divice = self.IPAD
        self.test_mod = test_mod

        self.activity_indicator = ui.ActivityIndicator(flex='LTRB')
        self.activity_indicator.style = 10

        if self.test_mod == self.NORMAL:
            self.width, self.height = ui.get_window_size()
        elif self.test_mod == self.TEST_IPHOE_P:
            # iPhone test
            self.width, self.height = 414, 736
        else:
            self.width, self.height = 736, 414
        if (self.width + self.height < 1024 + 768):
            self.divice = self.IPHONE

        self.mainTable = MainTable(self)
        self.nav_view = ui.NavigationView(self.mainTable)
        self.nav_view.flex = "WHLRTB"

        self.nav_view.add_subview(self.activity_indicator)
        self.add_subview(self.nav_view)

        self.loadUI()

        self.activity_indicator.bring_to_front()
Beispiel #5
0
    def __init__(self, rootpath):

        self.rootpath = rootpath
        self.appService = AppService(rootpath)
        self.configService = ConfigService(rootpath)

        self.isUpdating = False
        self.orientation = self.LANDSCAPE

        self.activity_indicator = ui.ActivityIndicator(flex='LTRB')
        self.activity_indicator.style = 10

        self.width, self.height = ui.get_window_size()

        self.mainTable = MainTable(self)
        self.nav_view = ui.NavigationView(self.mainTable)
        self.nav_view.name = 'AppWishList'
        self.nav_view.flex = "WHLRTB"

        self.nav_view.add_subview(self.activity_indicator)
        self.add_subview(self.nav_view)

        self.loadUI()

        self.activity_indicator.bring_to_front()
Beispiel #6
0
def _show_documentation(definition):
    reuse = get_config_value('documentation.reuse', True)
    frame = get_config_value('documentation.frame', (630, 110, 730, 350))
    tag = '__blackmamba.show_documentation'
    if not reuse:
        tag += ':{}'.format(definition.full_name)

    manager = overlay.get_manager()

    o = manager.get_overlay(tag)
    if o:
        o.title = definition.name
        o.content_view.text = definition.docstring()
        o.expand()
        o.become_active()
        return

    tv = ui.TextView(text=definition.docstring(),
                     background_color=get_theme_value('background_color'),
                     text_color=get_theme_value('text_color'),
                     font=get_editor_font())
    tv.editable = False

    window_size = ui.get_window_size()
    x = frame[0]
    y = frame[1]
    width = min(window_size[0] - x - 12, frame[2])
    height = min(window_size[1] - y - 12, frame[3])
    manager.present(definition.name, tv, frame=(x, y, width, height), tag=tag)
    def __init__(self, tabs=None, height=75, **kwargs):
        w, h = ui.get_window_size()
        self.flex = 'WH'
        self.frame = (0, 0, w, h)
        self.tab_height = height
        self.name = 'Select Drink'
        self.view_index = []

        self.content_view = ui.View(
            name='content',
            frame=(0, 0, w, (h - height)),
            flex='WB',
        )

        self.tab_view = ui.View(background_color='#eee',
                                frame=(0, (h - height), w, height),
                                border_color='#ccc',
                                border_width=0.5,
                                flex='WT')

        controller_options = dict(action=self.load_view, )

        if isinstance(tabs, list):
            controller_options['tabs'] = tabs

        self.controller = TabController(**controller_options)
        self.background_color = kwargs.pop('background_color', '#ffffff')

        # Add buttons

        button_width = int(self.width / len(self.controller.tabs))

        count = 0
        for tab in self.controller.tabs:
            vv = tab['button'].view
            self.view_index.append(vv)
            button = tab['button'].button
            button.x = (count * button_width)
            button.width = button_width
            button.y += 3
            self.tab_view.add_subview(button)

            if 0 < count < len(self.controller.tabs):
                sep = ui.ImageView(image=self.separator(),
                                   frame=((count * button_width), 0, 3, 70))
                self.tab_view.add_subview(sep)
            count += 1

        # add components as subviews
        if len(self.controller.tabs) > 0:
            # Use first tab as default view for now
            default_view = self.controller.tabs[0]['button'].view
            self.content_view.add_subview(default_view)

        self.add_subview(self.content_view)
        self.add_subview(self.tab_view)
Beispiel #8
0
    def __init__(self, rootpath, test_mod=0):
        self.name = 'AppWishList'
        self.rootpath = rootpath
        self.appService = AppService(rootpath)
        self.configService = ConfigService(rootpath)

        self.orientation = self.LANDSCAPE
        self.divice = self.IPAD
        self.test_mod = test_mod
        self.isUpdating = False

        self.viewKind = self.STAR
        self.starDeep = 0
        self.favoriteDeep = 0
        self.moreDeep = 0

        if self.test_mod == self.NORMAL:
            self.width, self.height = ui.get_window_size()
        elif self.test_mod == self.TEST_IPHOE_P:
            # iPhone test
            self.width, self.height = 414, 736
        else:
            self.width, self.height = 736, 414
        if (self.width + self.height < 1024 + 768):
            self.divice = self.IPHONE

        self.activity_indicator = ui.ActivityIndicator(flex='LTRB')
        self.activity_indicator.center = self.center
        self.activity_indicator.style = ui.ACTIVITY_INDICATOR_STYLE_GRAY

        self.starView = WishListView(self)
        self.favoriteView = CategoryView(self)
        self.moreView = SettingView(self)
        self.starNavi = ui.NavigationView(self.starView)
        self.favoriteNavi = ui.NavigationView(self.favoriteView)
        self.moreNavi = ui.NavigationView(self.moreView)

        self.bottomView = ui.View()
        self.starBtn = ui.Button()
        self.favoriteBtn = ui.Button()
        self.moreBtn = ui.Button()

        self.bottomView.add_subview(self.starBtn)
        self.bottomView.add_subview(self.favoriteBtn)
        self.bottomView.add_subview(self.moreBtn)

        self.add_subview(self.starNavi)
        self.add_subview(self.favoriteNavi)
        self.add_subview(self.moreNavi)
        self.add_subview(self.bottomView)
        self.add_subview(self.activity_indicator)

        self.loadUI()

        self.activity_indicator.bring_to_front()
Beispiel #9
0
    def infopop(self):
        """
        Modal style pop-up.
        """
        w, h = ui.get_window_size()
        width = round((w * 0.8), 0)
        height = round((h * 0.8 / 1.5), 0)

        if not self.infopopup:
            # Outer
            p = ui.ScrollView()
            p.border_color = '#ccc'
            p.border_width = 1

            p.width = width
            p.height = height
            p.corner_radius = 10

            t = ui.TextView()
            t.width = width
            t.height = height
            t.font = ('<System>', 12)
            t.content_inset = (5, 5, 5, 5)

            b = ui.Button()
            b.action = self.closepop
            b.image = ui.Image.named('iob:ios7_close_outline_24')
            b.width = 24
            b.height = 24
            b.x = (width - 29)
            b.y = 5

            t.editable = False

            t.add_subview(b)

            self.popuptext = t

            p.y = (((h - height) / 2) - 40)
            p.x = ((w - width) / 2)

            p.add_subview(self.popuptext)
            self.infopopup = p
            p.height = 0

        def animate_popup():
            """
            Method to animate the the popup, because its prettier.
            """
            self.infopopup.height = height

        self.infopopup.height = 0
        self.tv.add_subview(self.infopopup)
        ui.animate(animate_popup, 1)
Beispiel #10
0
	def __init__(self, url):
		self.width, self.height = ui.get_window_size()
		self.wv = ui.WebView(frame=self.bounds)
		self.wv.load_url(url)
		self.add_subview(self.wv)
		bi_back = ui.ButtonItem(image=ui.Image.named('iob:ios7_arrow_back_32'))
		bi_forward = ui.ButtonItem(image=ui.Image.named('iob:ios7_arrow_forward_32'))
		bi_back.action = self.go_back
		bi_forward.action = self.go_forward
		self.right_button_items = [bi_forward, bi_back]
		self.present()
    def viewlabel(label_text):
        w, h = ui.get_window_size()
        lh = (h - 60) / 2 - 5
        lbl = ui.Label(
            x=0,
            y=lh,
            text=label_text,
            name=label_text,
            alignment=ui.ALIGN_CENTER,
        )

        return lbl
Beispiel #12
0
 def __init__(self, url):
     self.width, self.height = ui.get_window_size()
     self.wv = ui.WebView(frame=self.bounds)
     self.wv.load_url(url)
     self.add_subview(self.wv)
     bi_back = ui.ButtonItem(image=ui.Image.named('iob:ios7_arrow_back_32'))
     bi_forward = ui.ButtonItem(
         image=ui.Image.named('iob:ios7_arrow_forward_32'))
     bi_back.action = self.go_back
     bi_forward.action = self.go_forward
     self.right_button_items = [bi_forward, bi_back]
     self.present()
Beispiel #13
0
 def tableview_accessory_button_tapped(self, tableview, section, row, **kwargs):
     v = ui.TableView()
     v.name = tableview.data_source.items[row]
     v.data_source = ClassBrowserController(tableview.data_source.items[row])
     v.autoresizing = 'wh'
     v.reload()
     if ui.get_window_size().width <= 320:
         v.present('full_screen')
     else:
         v.width=600
         v.height=200
         v.present('popover', popover_location=(0,0))
Beispiel #14
0
    def __init__(self, title="Alert", info="", act=None):
        self.value = 0
        self.act = act

        self.frame = (0, 0, 250, 180)
        self.background_color = "white"
        self.win_w, self.win_h = ui.get_window_size()
        self.win_h -= 50
        if self.win_w > 760:
            self.win_w = 250
            self.win_h = 180

        self.titleLabel = ui.Label()
        self.titleLabel.text = title
        self.titleLabel.font = ("<system>", 20)
        self.titleLabel.text_color = "#000"
        self.titleLabel.alignment = ui.ALIGN_CENTER
        self.titleLabel.frame = (0, 20, self.win_w, 20)

        self.infoLabel = ui.Label()
        self.infoLabel.text = info
        self.infoLabel.font = ("<system>", 16)
        self.infoLabel.text_color = "#5a5a5a"
        self.infoLabel.alignment = ui.ALIGN_CENTER
        self.infoLabel.frame = (0, self.titleLabel.height, self.win_w,
                                self.win_h - self.titleLabel.height - 50)

        self.okBtn = ui.Button()
        self.okBtn.title = "确定"
        self.okBtn.border_width = 1
        self.okBtn.frame = (-1, self.win_h - 50, self.win_w / 2 + 1, 50 + 1)
        self.okBtn.background_color = "white"
        self.okBtn.border_color = "#eaeaea"
        #self.okBtn.corner_radius=5
        self.okBtn.action = self.okAct

        self.closeBtn = ui.Button()
        self.closeBtn.title = "取消"
        self.closeBtn.border_width = 1
        self.closeBtn.frame = (self.win_w / 2, self.win_h - 50, self.win_w / 2,
                               50 + 1)
        self.closeBtn.background_color = "white"
        self.closeBtn.border_color = "#eaeaea"
        #self.closeBtn.corner_radius=5
        self.closeBtn.action = self.closeAct

        self.add_subview(self.titleLabel)
        self.add_subview(self.infoLabel)
        self.add_subview(self.okBtn)
        self.add_subview(self.closeBtn)

        self.present("sheet", hide_title_bar=True)
        self.wait_modal()
Beispiel #15
0
  def main(self):
    data.main_view = self.MainView()
    w, h = ui.get_window_size()
    data.main_view.frame = (0, 0, w, h)
    
    data.gestures_instance = Gestures.Gestures()
    data.gestures_instance.add_tap(data.main_view, self.simple_tap)

    data.hud_layer = Hud()
    self.next_stage(selector.SelectorStage())

    data.main_view.present(style='fullscreen', hide_title_bar=True)
    def __init__(self):

        self.animate_demo = True
        self.flex = 'WH'
        self.name = 'AWS Image Export'
        self.background_color = '#fff'
        w, h = ui.get_window_size()
        self.frame = (0, 0, w, h)
        buffer = 20

        # Setup Exporter

        self.exporter = AWSImageExporter()

        # Setup images
        self.image_list = {}
        self.all_images = []

        # Setup Categories
        self.categories = []

        # Grab Images into above vars
        self.load_images()

        # Remove duplicates in categories, and sort
        self.categories = sorted(list(set(self.categories)))

        pyui = bz2.decompress(b64decode(self._load_ui()))
        self.content_view = ui.load_view_str(pyui.decode('utf-8'))
        self.content_view.background_color = '#333'
        self.content_view.frame = self.frame
        self.content_view.flex = 'WH'
        self.add_subview(self.content_view)

        # Setup the various connections
        self.main = self.content_view['main']
        self.label_image_num = self.main['image_num']
        self.preview_image = self.main['preview_image']
        self.preview_category = self.main['preview_category']
        self.list_set = self.main['list_set']
        self.list_view = self.main['list_view']
        self.label_category_preview = self.main['label_category_preview']
        self.label_image_preview = self.main['label_image_preview']

        # Default View
        self.preview_category.image = ui.Image(
            'images/Database_AmazonElasticCache_Memcached.png')
        self.preview_image.image = ui.Image(
            'images/Database_AmazonElasticCache_Redis.png')

        self.label_image_num.text = str(len(self.all_images))
Beispiel #17
0
 def tableview_accessory_button_tapped(self, tableview, section, row, **kwargs):
     obj = tableview.data_source.fworks['frameworks'][tableview.data_source.fworks['flist'][row]]
     v = ui.TableView()
     v.row_height = 120
     v.name = '{} Info'.format(tableview.data_source.fworks['flist'][row].split('.')[-1])
     v.data_source = InfoDataSource(obj)
     v.autoresizing = 'wh'
     v.reload()
     if ui.get_window_size().width <= 320:
         v.present('full_screen')
     else:
         v.width=300
         v.height=200
         v.present('popover')
Beispiel #18
0
 def tableview_accessory_button_tapped(self, tableview, section, row,
                                       **kwargs):
     v = ui.TableView()
     v.name = tableview.data_source.items[row]
     v.data_source = ClassBrowserController(
         tableview.data_source.items[row])
     v.autoresizing = 'wh'
     v.reload()
     if ui.get_window_size().width <= 320:
         v.present('full_screen')
     else:
         v.width = 600
         v.height = 200
         v.present('popover', popover_location=(0, 0))
Beispiel #19
0
 def tableview_accessory_button_tapped(self, tableview, section, row, **kwargs):
     obj = tableview.data_source.fworks['frameworks'][tableview.data_source.fworks['flist'][row]]
     v = ui.TableView()
     v.row_height = 120
     v.name = '{} Info'.format(tableview.data_source.fworks['flist'][row].split('.')[-1])
     v.data_source = BundleInfoDataSource(obj)
     v.autoresizing = 'wh'
     v.reload()
     if ui.get_window_size().width <= 320:
         v.present('full_screen')
     else:
         v.width = 300
         v.height = 200
         v.present('popover')
Beispiel #20
0
 def __init__(self):
     width, height = ui.get_window_size()
     canvas_size = max(width, height)
     frame = (0, 0, canvas_size, canvas_size)
     self.background_color = '#1F2326'
     self.tint_color = 'white'  #274197'
     iv = ui.ImageView(frame=frame)
     iv.background_color = (0, 0, 0, 0)
     pv = PathView(frame=self.bounds)
     pv.background_color = (0, 0, 0, 0)
     pv.action = self.path_action
     self.add_subview(iv)
     self.add_subview(pv)
     self.image_view = iv
     self.history = []
Beispiel #21
0
 def tableview_accessory_button_tapped(self, tableview, section, row, **kwargs):
     t = ui.TableView()
     v = ui.NavigationView(t)
     v.name = tableview.data_source.items[row]
     t.data_source = ClassBrowserController(tableview.data_source.items[row])
     t.delegate = SuperClassDelegate()
     v.autoresizing = 'wh'
     t.reload()
     if ui.get_window_size().width <= 320:
         v.present('full_screen')
     else:
         v.width = 600
         v.height = 800
         v.flex = 'HR'
         v.present('popover', popover_location=(0, 0))
Beispiel #22
0
	def loadUI(self):
		self.name="更新数据"
		self.frame=(0,0,300,150)
		self.background_color="white"
		self.win_w,_=ui.get_window_size()
		if self.win_w>760:
			self.win_w=300
		
		self.infoLabel.text="数据更新中,请等待..."
		self.infoLabel.frame=(0,20,self.win_w,30)
		self.infoLabel.alignment=ui.ALIGN_CENTER
		self.infoLabel.font=("<system>",16)
		
		self.percentageLabel.frame=(20,60,self.win_w-40,40)
		self.percentageLabel.border_width=1
		self.percentageLabel.border_color="#434343"
		self.percentageLabel.text="{f:.2f}%".format(f=(self.index/self.max*100))
		self.percentageLabel.text_color="#d4d4d4"
		self.percentageLabel.alignment=ui.ALIGN_CENTER
		
		self.processionLabel.frame=(20,60,(self.win_w-40)*(self.index/self.max),40)
		self.processionLabel.background_color="#30ba3c"
Beispiel #23
0
    def main(self):
        """
        Application's main entry point
        """
        tv = ui.TableView()
        w, h = ui.get_window_size()
        tv.width = w
        tv.height = h
        tv.name = "Download Repo"
        ds = ui.ListDataSource(self.saved)
        ds.action = self.download
        ds.move_enabled = False
        ds.edit_action = self.delrepo
        tv.data_source = ds
        tv.delegate = ds

        add = ui.ButtonItem(action=self.add_repo,
                            image=ui.Image.named('iob:ios7_plus_empty_32'))

        tv.right_button_items = [add]
        self.tv = tv

        self.tv.present()
Beispiel #24
0
 def __init__(self, url):
     self.width, self.height = ui.get_window_size()
     self.background_color = 'black'
     # the webview
     self.wv = ui.WebView(frame=self.bounds)
     self.wv.background_color = 'black'
     self.finished = False
     self.current_url = None
     self.next_url = ""
     self.start_workerThread()
     self.add_subview(self.wv)
     # a top view for catching gesture events
     self.gv = ui.View(frame=self.bounds)
     self.gv.alpha = 0.05
     self.gv.background_color = 'white'
     self.add_subview(self.gv)
     self.gv.bring_to_front()
     # some variables for setting the layout
     self.ty = -27
     self.sx = 1
     self.applyVerticalOffset()
     self.applyScale()
     # view adjustment per url are saved here
     self.registry = {}
     self.readRegistry()
     # gesture setup
     g = Gestures()
     g.add_pan(self.gv, self.pan_handler, 1, 1)
     g.add_pinch(self.gv, self.pinch_handler)
     g.add_long_press(self.gv, self.long_press_handler)
     # launch the layout
     self.present("full_screen",
                  hide_title_bar=True,
                  orientations=['landscape'])
     # load the url
     self.loadURL(url)
Beispiel #25
0
    def __init__(self, url):
        self.finished = False
        self.start_workerThread()
        self.width, self.height = ui.get_window_size()
        self.background_color = 'black'
        # the webview
        self.wv = wkwebview.WKWebView(frame=self.bounds, flex='WH')
        self.wv.delegate = MyWebViewDelegate(self.wv)

        self.wv.background_color = 'black'
        self.add_subview(self.wv)

        bi_back = ui.ButtonItem(image=ui.Image.named('iob:ios7_arrow_back_32'),
                                action=self.goBack)
        bi_forward = ui.ButtonItem(
            image=ui.Image.named('iob:ios7_arrow_forward_32'),
            action=self.goForward)
        self.right_button_items = [bi_forward, bi_back]

        self.clearCache()
        self.loadURL(url)

        # launch the layout
        self.present("full_screen", hide_title_bar=False)
Beispiel #26
0
    def setup(self):
        self.background_color = (0, 0, .5)
        self.v = None
        self.INPUT_ACTION_TAKEN = False
        self.nextT = 0
        # set up all permanent nodes and subnodes

        self.face = SpriteNode('emj:Smiling_2',
                               position=(500, 350),
                               parent=self)
        self.face.alpha = 0
        self.face.z_position = 100000

        self.buttonParmPopup = ShapeNode(ui.Path.rounded_rect(
            0, 0, 60, 60, 12),
                                         position=(975, 30),
                                         fill_color='green',
                                         parent=self)

        self.buttonAllAuto = ShapeNode(ui.Path.rounded_rect(0, 0, 60, 60, 12),
                                       position=(875, 30),
                                       fill_color='white',
                                       parent=self)

        self.buttonAuto = ShapeNode(ui.Path.rounded_rect(0, 0, 60, 60, 12),
                                    position=(775, 30),
                                    fill_color='orange',
                                    parent=self)

        self.buttonPile = ShapeNode(ui.Path.rounded_rect(0, 0, 60, 60, 12),
                                    position=(180, 30),
                                    fill_color='purple',
                                    parent=self)

        self.buttonSet = ShapeNode(ui.Path.rounded_rect(0, 0, 60, 60, 12),
                                   position=(60, 30),
                                   fill_color='red',
                                   parent=self)

        self.messageBoard = Node(position=(50, 300), alpha=0, parent=self)
        #self.rect = SpriteNode(color='black', parent=self.messageBoard)
        self.rect = ShapeNode(outlinePath,
                              color='#ff4300',
                              parent=self.messageBoard)
        self.rect.anchor_point = (0, 0)
        self.messageBoard.z_position = 100
        self.message = LabelNode('',
                                 position=(0, 0),
                                 color='#000000',
                                 font=('Helvetica', 100),
                                 parent=self.messageBoard)
        self.message.anchor_point = (0, 0)

        self.scoreBoard = Node(position=(10, 750), parent=self)
        self.score = LabelNode('', parent=self.scoreBoard)
        self.score.anchor_point = (0, 5)

        self.deckInfo = Node(position=(10, 725), parent=self)
        self.deckLabel = LabelNode('', parent=self.deckInfo)
        self.deckLabel.anchor_point = (0, 5)

        self.dealInfo = Node(position=(10, 700), parent=self)
        self.dealLabel = LabelNode('', color='yellow', parent=self.dealInfo)
        self.dealLabel.anchor_point = (0, 5)

        self.timerBar = ShapeNode(ui.Path.rect(0, 0, 5, 700),
                                  position=(1020, 0),
                                  anchor_point=(0, 0),
                                  fill_color='yellow',
                                  parent=self)

        ws = ui.get_window_size()
        self.setsFound = Node(position=(0, ws[1]), parent=self)

        # save number of permanent nodes
        self.numChildrenSetup = len(self.children)

        self.start()
Beispiel #27
0
  def main(self):
    self.main_view = ui.View()
    w, h = ui.get_window_size()
    self.main_view.frame = (0, 0, w, h)
    self.main_view.name = 'vehicle demo'
    
    self.close_button = ui.Button()
    self.close_button.action = self.close
    self.close_button.frame = (20, 40, 40, 40)
    self.close_button.background_image = ui.Image.named('emj:No_Entry_2')

    if DEBUG:  
      self.scene_view = scn.View((0,25,w,h-25), superView=self.main_view)
      self.scene_view.showsStatistics = True
    else:
      self.scene_view = scn.View((0, 0, w, h), superView=self.main_view)
    self.scene_view.preferredFramesPerSecond = 30
      
    self.scene_view.autoresizingMask = scn.ViewAutoresizing.FlexibleHeight | scn.ViewAutoresizing.FlexibleWidth
    self.scene_view.allowsCameraControl = False
    
    self.scene_view.scene = scn.Scene()
    self.root_node = self.scene_view.scene.rootNode 
    
    self.scene_view.backgroundColor = (.77, .97, 1.0)
    self.scene_view.delegate = self
    
    self.physics_world = self.scene_view.scene.physicsWorld
    self.physics_world.speed = 2.
    self.physics_world.contactDelegate = self
    
    if DEBUG:
      marker1 = scn.Sphere(0.1)
      marker1.firstMaterial.emission.contents = (1.0, .14, .14)
      marker1.firstMaterial.diffuse.contents = (.0, .0, .0)
      Demo.marker_node1 = scn.Node.nodeWithGeometry(marker1)
      Demo.marker_node1.name = 'marker1'
      self.root_node.addChildNode(Demo.marker_node1)
     
      marker2 = scn.Sphere(0.1)
      marker2.firstMaterial.emission.contents = (.17, .0, 1.0)
      marker2.firstMaterial.diffuse.contents = (.0, .0, .0)
      Demo.marker_node2 = scn.Node.nodeWithGeometry(marker2)
      Demo.marker_node2.name = 'marker2'
      self.root_node.addChildNode(Demo.marker_node2)
    
    floor_geometry = scn.Floor()
    floor_geometry.reflectivity = 0.05
    tile_image = ui.Image.named('plf:Ground_DirtCenter')
    tile_number = 5
    tile_factor = scn.Matrix4(tile_number, 0.0, 0.0, 0.0, 0.0, tile_number, 0.0, 0.0, 0.0, 0.0, tile_number, 0.0, 0.0, 0.0, 0.0, 1.0)
    floor_geometry.firstMaterial.diffuse.contents = tile_image
    floor_geometry.firstMaterial.diffuse.intensity = 0.8
    floor_geometry.firstMaterial.diffuse.contentsTransform = tile_factor
    floor_geometry.firstMaterial.diffuse.wrapS, floor_geometry.firstMaterial.diffuse.wrapT = scn.WrapMode.Repeat, scn.WrapMode.Repeat
    floor_geometry.firstMaterial.locksAmbientWithDiffuse = True
    self.floor_node = scn.Node.nodeWithGeometry(floor_geometry)
    self.floor_node.name = 'Floor'
    self.floor_node.physicsBody = scn.PhysicsBody.staticBody()
    self.root_node.addChildNode(self.floor_node)
    
    cars = [dict(name='red', position=(5, 0, 0), volume=1.),
            dict(name='yellow', too_far=25, body_color=(1.0, .78, .0), position=(-5, 0, -2), sound='game:Pulley', volume=0.1),
            dict(name='blue', too_far=30, body_color=(.0, .61, 1.0), position=(-12, 0, -6), sound='game:Woosh_1', volume=0.5),
            dict(name='green', too_far=18, body_color=(.0, .82, .28), position=(10, 0, -10), sound='casino:DiceThrow3', volume=0.8),
            dict(name='pink', too_far=20, body_color=(.91, .52, .62), position=(5, 0, 10), sound='casino:DieThrow3', volume=0.5)]      
    self.cars =[Car(world=self, props=cars[i]) for i in range(min(MAXCARS, len(cars)))]
    
    self.free_flags = []
    for i in range(2*len(self.cars)):
      node = scn.Node()
      self.free_flags.append(node)
      self.root_node.addChildNode(node)
    self.used_flags = {}
    
    self.crash = Sparks().particleSystem
    self.crash_sound = scn.AudioSource('game:Crashing')
    self.crash_action = scn.Action.playAudioSource(self.crash_sound, False)
    
    self.road_blocks_node = scn.Node()
    self.road_blocks = []
    
    self.road_blocks.append(RoadBlock(w=1.6, l=25, name='block 0', position=(28, 6)))
    self.road_blocks.append(RoadBlock(w=20, l=1.6, name='block 1', position=(-2, -12)))
    self.road_blocks.append(RoadBlock(w=8, l=1.6, name='block 2', position=(-10, 6), rotation=-math.pi/6))
    self.road_blocks.append(RoadBlock(w=40, l=1.6, name='block 3', position=(-40, 0), rotation=-math.pi/3))
    self.road_blocks.append(RoadBlock(w=0.8, h=3, l=0.8, name='start', position=(0, 0)))
    
    for aBlock in self.road_blocks: self.road_blocks_node.addChildNode(aBlock.block_node)    
    self.root_node.addChildNode(self.road_blocks_node)

    self.camera_node = scn.Node()
    self.camera_node.camera = scn.Camera()
    self.camera_node.camera.zFar = 150
    carPos = self.cars[0].node.position
    self.camera_node.position = scn.Vector3(carPos.x+5, 10, carPos.z+30)    
    self.root_node.addChildNode(self.camera_node)
    
    self.light_node = scn.Node()
    self.light_node.position = (50, 50, 50)
    self.light_node.lookAt(self.root_node.position)
    self.light = scn.Light()
    self.light.type = scn.LightTypeDirectional
    self.light.castsShadow = True
    self.light.shadowSampleCount = 16
    self.light.color = (.95, 1.0, .98)
    self.light_node.light = self.light
    self.root_node.addChildNode(self.light_node)
    
    self.ambient_node = scn.Node()
    self.ambient = scn.Light()
    self.ambient.type = scn.LightTypeAmbient
    self.ambient.color = (.38, .42, .45, .1)
    self.ambient_node.light = self.ambient
    self.root_node.addChildNode(self.ambient_node)
    
    self.scene_view.pointOfView = self.camera_node
    
    if DEBUG: self.main_view.add_subview(Demo.status_label)
    
    self.close = False
    self.shut_down = False
    self.main_view.add_subview(self.close_button)
    self.main_view.present(hide_title_bar=~DEBUG)
Beispiel #28
0
class Demo:
  if DEBUG:
    w, h = ui.get_window_size()
    status_label = ui.Label()
    status_label.frame = (0,0,w,25)
    status_label.background_color = 'white'
    status_label.text = 'Running'
    def setStatus(self):
      line = 'cache: '+str(scn.cacheSize())+' '
      for aCar in self.cars:
        prg = str(aCar.current_program.name)
        if aCar.current_program == CarProgram.reverse:
          prg += '/'+str(aCar.program_table[aCar.current_program].counter)
        line += aCar.name+': '+ prg +'  '
      self.status_label.text = line
    
  @classmethod
  def run(cls):
    cls().main()
    
  @on_main_thread
  def main(self):
    self.main_view = ui.View()
    w, h = ui.get_window_size()
    self.main_view.frame = (0, 0, w, h)
    self.main_view.name = 'vehicle demo'
    
    self.close_button = ui.Button()
    self.close_button.action = self.close
    self.close_button.frame = (20, 40, 40, 40)
    self.close_button.background_image = ui.Image.named('emj:No_Entry_2')

    if DEBUG:  
      self.scene_view = scn.View((0,25,w,h-25), superView=self.main_view)
      self.scene_view.showsStatistics = True
    else:
      self.scene_view = scn.View((0, 0, w, h), superView=self.main_view)
    self.scene_view.preferredFramesPerSecond = 30
      
    self.scene_view.autoresizingMask = scn.ViewAutoresizing.FlexibleHeight | scn.ViewAutoresizing.FlexibleWidth
    self.scene_view.allowsCameraControl = False
    
    self.scene_view.scene = scn.Scene()
    self.root_node = self.scene_view.scene.rootNode 
    
    self.scene_view.backgroundColor = (.77, .97, 1.0)
    self.scene_view.delegate = self
    
    self.physics_world = self.scene_view.scene.physicsWorld
    self.physics_world.speed = 2.
    self.physics_world.contactDelegate = self
    
    if DEBUG:
      marker1 = scn.Sphere(0.1)
      marker1.firstMaterial.emission.contents = (1.0, .14, .14)
      marker1.firstMaterial.diffuse.contents = (.0, .0, .0)
      Demo.marker_node1 = scn.Node.nodeWithGeometry(marker1)
      Demo.marker_node1.name = 'marker1'
      self.root_node.addChildNode(Demo.marker_node1)
     
      marker2 = scn.Sphere(0.1)
      marker2.firstMaterial.emission.contents = (.17, .0, 1.0)
      marker2.firstMaterial.diffuse.contents = (.0, .0, .0)
      Demo.marker_node2 = scn.Node.nodeWithGeometry(marker2)
      Demo.marker_node2.name = 'marker2'
      self.root_node.addChildNode(Demo.marker_node2)
    
    floor_geometry = scn.Floor()
    floor_geometry.reflectivity = 0.05
    tile_image = ui.Image.named('plf:Ground_DirtCenter')
    tile_number = 5
    tile_factor = scn.Matrix4(tile_number, 0.0, 0.0, 0.0, 0.0, tile_number, 0.0, 0.0, 0.0, 0.0, tile_number, 0.0, 0.0, 0.0, 0.0, 1.0)
    floor_geometry.firstMaterial.diffuse.contents = tile_image
    floor_geometry.firstMaterial.diffuse.intensity = 0.8
    floor_geometry.firstMaterial.diffuse.contentsTransform = tile_factor
    floor_geometry.firstMaterial.diffuse.wrapS, floor_geometry.firstMaterial.diffuse.wrapT = scn.WrapMode.Repeat, scn.WrapMode.Repeat
    floor_geometry.firstMaterial.locksAmbientWithDiffuse = True
    self.floor_node = scn.Node.nodeWithGeometry(floor_geometry)
    self.floor_node.name = 'Floor'
    self.floor_node.physicsBody = scn.PhysicsBody.staticBody()
    self.root_node.addChildNode(self.floor_node)
    
    cars = [dict(name='red', position=(5, 0, 0), volume=1.),
            dict(name='yellow', too_far=25, body_color=(1.0, .78, .0), position=(-5, 0, -2), sound='game:Pulley', volume=0.1),
            dict(name='blue', too_far=30, body_color=(.0, .61, 1.0), position=(-12, 0, -6), sound='game:Woosh_1', volume=0.5),
            dict(name='green', too_far=18, body_color=(.0, .82, .28), position=(10, 0, -10), sound='casino:DiceThrow3', volume=0.8),
            dict(name='pink', too_far=20, body_color=(.91, .52, .62), position=(5, 0, 10), sound='casino:DieThrow3', volume=0.5)]      
    self.cars =[Car(world=self, props=cars[i]) for i in range(min(MAXCARS, len(cars)))]
    
    self.free_flags = []
    for i in range(2*len(self.cars)):
      node = scn.Node()
      self.free_flags.append(node)
      self.root_node.addChildNode(node)
    self.used_flags = {}
    
    self.crash = Sparks().particleSystem
    self.crash_sound = scn.AudioSource('game:Crashing')
    self.crash_action = scn.Action.playAudioSource(self.crash_sound, False)
    
    self.road_blocks_node = scn.Node()
    self.road_blocks = []
    
    self.road_blocks.append(RoadBlock(w=1.6, l=25, name='block 0', position=(28, 6)))
    self.road_blocks.append(RoadBlock(w=20, l=1.6, name='block 1', position=(-2, -12)))
    self.road_blocks.append(RoadBlock(w=8, l=1.6, name='block 2', position=(-10, 6), rotation=-math.pi/6))
    self.road_blocks.append(RoadBlock(w=40, l=1.6, name='block 3', position=(-40, 0), rotation=-math.pi/3))
    self.road_blocks.append(RoadBlock(w=0.8, h=3, l=0.8, name='start', position=(0, 0)))
    
    for aBlock in self.road_blocks: self.road_blocks_node.addChildNode(aBlock.block_node)    
    self.root_node.addChildNode(self.road_blocks_node)

    self.camera_node = scn.Node()
    self.camera_node.camera = scn.Camera()
    self.camera_node.camera.zFar = 150
    carPos = self.cars[0].node.position
    self.camera_node.position = scn.Vector3(carPos.x+5, 10, carPos.z+30)    
    self.root_node.addChildNode(self.camera_node)
    
    self.light_node = scn.Node()
    self.light_node.position = (50, 50, 50)
    self.light_node.lookAt(self.root_node.position)
    self.light = scn.Light()
    self.light.type = scn.LightTypeDirectional
    self.light.castsShadow = True
    self.light.shadowSampleCount = 16
    self.light.color = (.95, 1.0, .98)
    self.light_node.light = self.light
    self.root_node.addChildNode(self.light_node)
    
    self.ambient_node = scn.Node()
    self.ambient = scn.Light()
    self.ambient.type = scn.LightTypeAmbient
    self.ambient.color = (.38, .42, .45, .1)
    self.ambient_node.light = self.ambient
    self.root_node.addChildNode(self.ambient_node)
    
    self.scene_view.pointOfView = self.camera_node
    
    if DEBUG: self.main_view.add_subview(Demo.status_label)
    
    self.close = False
    self.shut_down = False
    self.main_view.add_subview(self.close_button)
    self.main_view.present(hide_title_bar=~DEBUG)

    
  def close(self, sender):
    self.close = True
    self.main_view.remove_subview(self.close_button)
    
  def shutDown(self):
    self.shut_down = True
    for aCar in self.cars:
      aCar.smoker_node.removeAllParticleSystems()
      aCar.tire_node.removeAllParticleSystems()
      if ENGINESOUND:
        aCar.sound.loops = False
        aCar.chassis_node.removeAllAudioPlayers()
    for aNode in self.used_flags.values():
      aNode.removeAllParticleSystems()
      aNode.removeAllAudioPlayers()
    self.physics_world.removeAllBehaviors()
    self.scene_view.scene.paused = True
    self.main_view.close()
    ui.delay(self.exit, 1.5)
    
  def exit(self):
    raise SystemExit()
    
  def update(self, view, atTime):
    if self.close:
      if ~self.shut_down: self.shutDown()
      return
      
    cx, cz, node_dist = 0., 0., 99999999999.
    camPos = self.camera_node.position
    for aCar in self.cars:
      aCar.current_speed = abs(aCar.vehicle.speedInKilometersPerHour)
      aCar.node = aCar.chassis_node.presentationNode
      aCar.position = aCar.node.position
      cx += aCar.position.x
      cz += aCar.position.z
      node_dist = min(node_dist, abs(aCar.position.z-camPos.z))

      if aCar.current_program == CarProgram.reverse or aCar.current_program == CarProgram.obstacle:
        pass
      else:
        obstacles = list(view.nodesInsideFrustumWithPointOfView(aCar.camera_node.presentationNode))
        try:
          obstacles.remove(self.floor_node)
        except ValueError: pass
        if len(obstacles) > 0:
          aCar.setProgram(CarProgram.obstacle)
          
        elif length(aCar.position) > random.uniform(aCar.too_far, aCar.too_far+30):
          aCar.setProgram(CarProgram.turn_back)

      aCar.move(view, atTime)
      
    self.camera_node.lookAt((cx/len(self.cars), camPos.y, cz/len(self.cars)))
    if sum(1 for aCar in self.cars if view.isNodeInsideFrustum(aCar.node, self.camera_node)) < len(self.cars):
      self.camera_node.position = (camPos.x, camPos.y, camPos.z+0.1)
    elif node_dist < 15:
      self.camera_node.position = (camPos.x, camPos.y, camPos.z+0.05)
    elif node_dist > 35:
      self.camera_node.position = (camPos.x, camPos.y, camPos.z-0.03)
            
  def didBeginContact(self, aWorld, aContact):
    key = frozenset([aContact.nodeA, aContact.nodeB])
    if self.free_flags and key not in self.used_flags:
      flag_node = self.free_flags.pop()
      self.used_flags[key] = flag_node
      contactPoint = aContact.contactPoint
      flag_node.position = (contactPoint.x, contactPoint.y, contactPoint.z)
      flag_node.addParticleSystem(self.crash)
      flag_node.runAction(self.crash_action)
      
  def didUpdateContact(self, aWorld, aContact):
    key = frozenset([aContact.nodeA, aContact.nodeB])
    if key in self.used_flags:
      flag_node = self.used_flags[key]
      contactPoint = aContact.contactPoint
      flag_node.position = (contactPoint.x, contactPoint.y, contactPoint.z)
          
  def didEndContact(self, aWorld, aContact):
    key = frozenset([aContact.nodeA, aContact.nodeB])
    if key in self.used_flags:
      flag_node = self.used_flags.pop(key)
      flag_node.removeAllParticleSystems()
      self.free_flags.append(flag_node)
Beispiel #29
0
MyGLViewDelegate = create_objc_class('MyGLViewDelegate',
                                     methods=[glkView_drawInRect_],
                                     protocols=['GLKViewDelegate'])


class ChristmasScene(Scene):
    def setup(self):
        objv = ObjCInstance(self.view)

        delegate = MyGLViewDelegate.alloc().init()
        objv.glkView().setDelegate_(delegate)
        objv.glkView().setOpaque_(False)

        sp = SpriteNode('emj:Christmas_Tree',
                        anchor_point=(0, 0),
                        position=(500, 300),
                        parent=self)


w, h = ui.get_window_size()
webview = ui.WebView(frame=(w / 4, 0, w / 2, h))
webview.load_url('http://google.com')
gameview = SceneView()
gameview.scene = ChristmasScene()

gameview.add_subview(webview)
webview.send_to_back()

gameview.present('full_screen')
Beispiel #30
0
    def start(self):
        # remove added card nodes and free their positions
        for node in self.children[self.numChildrenSetup:]:
            freePositions[node.posInd] = True
            node.remove_from_parent()

        # clear out self.setsFound
        for child in self.setsFound.children:
            child.remove_from_parent()

        self.numCorrectSets = 0
        self.numBadSets = 0
        self.numAbortSetCall = 0
        self.numCorrectDeals = 0
        self.numBadDeals = 0
        self.numAutoSets = 0
        self.numAutoDeals = 0

        ws = ui.get_window_size()
        self.xDisp = self.xDispCol = ws[0] - 225
        self.yDisp = -150

        self.startNextTouch = False
        self.cardsOnTable = []
        self.setAutoFound = []
        self.cardsLeft = []
        self.setsDisplayed = []

        # make backend deck
        if parm['EASY']:
            attNum = parm['ATTRIBUTE_idx']
            if attNum == 0:
                attNum = random.randrange(3)
            else:
                attNum -= 1

            propertyFixed = parm['PROPERTY']
            if propertyFixed == 'Random':
                propertyFixed = random.choice(
                    ['Color', 'Number', 'Shape', 'Shade'])
            if propertyFixed == 'Color':
                self.deck = makeDeck(colorSlice=(attNum, attNum + 1, 1))
            elif propertyFixed == 'Number':
                self.deck = makeDeck(numberSlice=(attNum, attNum + 1, 1))
            elif propertyFixed == 'Shape':
                self.deck = makeDeck(shapeSlice=(attNum, attNum + 1, 1))
            elif propertyFixed == 'Shade':
                self.deck = makeDeck(shadeSlice=(attNum, attNum + 1, 1))
        else:
            self.deck = makeDeck()

        # make backend initial deal
        self.deal = makeDeal(self.deck)
        # print(self.deal)
        self.deckLabel.text = checkDeck(self.deck)
        self.dealLabel.text = checkDeck(self.deal)

        # create and draw card nodes of deal in grid
        for cardData in self.deal:
            ctmp = Card(None, None, *cardData)
            # print(ctmp.position)
            self.add_child(ctmp)
            self.cardsOnTable.append(ctmp)

        # FIX only for the initial deal!
        for i, subnode in enumerate(self.children[self.numChildrenSetup:]):
            subnode.z_position = -i

        self.cardTouched = None
        self.buttonTouchId = None
        self.userCalledSet = False
        self.userCardsSelected = []
        self.showAllThenAbort = False
        self.message.text = ''
        self.messageBoard.alpha = 0
        self.nextT = self.t + parm['DELAY']
        self.startTime = self.t
        self.lastScoreShowTime = self.t
    # Drop Down
    v = ui.View()
    v.name = 'picker'
    v.flex = 'WH'
    v.background_color = '#fff'
    items = [
        'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'none',
        'ten'
    ]
    items = items + items
    dd = DropdownListView(items)
    dd.frame = (15, 10, 220, 32)

    # Add checkbox

    w, _ = ui.get_window_size()
    check1 = uiCheckbox('love_python', text='I love Python')
    check2 = uiCheckbox('is_nerdy', text='I am kind of nerdy..')
    check3 = uiCheckbox('hate_coding', text='I Hate Coding')
    check2.y = (check1.height + 10)
    check3.y = (check2.y + check2.height + 5)

    checkbox_holder = ui.View(frame=(5, 100, (w - 10), 250),
                              border_width=.5,
                              background_color='#eeeeee')
    checkbox_holder.add_subview(check1)
    checkbox_holder.add_subview(check2)
    checkbox_holder.add_subview(check3)

    v.add_subview(checkbox_holder)
    v.add_subview(dd)
Beispiel #32
0
    def __init__(self, view):
        self.connect_limit = 5

        d = datetime.datetime.today()
        folder = d.strftime("%Y-%m-%d")
        self.save_dir = to_abs_path('Transfer3', folder)
        #print folder
        if not os.path.isdir(self.save_dir):
            os.makedirs(self.save_dir)

        self.app_root_path = os.path.dirname(__file__)
        self.core_path = os.path.join(self.app_root_path, 'core')
        self.cert_path = os.path.join(self.app_root_path, 'server.pem')

        self.view = view
        self.sc_select = self.view['sc_select']
        self.sc_select.action = self.sc_select_action

        self.send_view = self.view['send_view']
        self.tv_receiver = self.view['send_view']['tv_receiver']

        self.tv_receiver.data_source.tableview_cell_for_row = self.tv_receiver_cell_for_row
        self.tv_receiver.data_source.tableview_delete = self.tv_receiver_delete
        self.tv_receiver.delegate.tableview_did_select = self.tv_receiver_did_select
        self.tv_receiver.delegate.tableview_accessory_button_tapped = self.tv_receiver_info_btn

        self.tf_send_text = self.view['send_view']['tf_send_text']
        self.tf_send_text.delegate = self.tf_send_text_Delegate
        self.tf_send_text.delegate.textfield_did_change = self.tf_send_text_did_change
        self.tf_send_text.autocorrection_type = False
        self.tf_send_text.spellchecking_type = False
        self.tf_send_text.autocapitalization_type = ui.AUTOCAPITALIZE_NONE
        self.tf_send_text.text = clipboard.get()

        self.bt_select = self.view['send_view']['bt_select']
        self.bt_select.action = self.bt_select_action

        self.bt_send = self.view['send_view']['bt_send']
        self.bt_send.action = self.bt_send_action

        self.bt_send_text = self.view['send_view']['bt_send_text']
        self.bt_send_text.action = self.bt_send_text_action

        self.bt_clear = self.view['send_view']['bt_clear']
        self.bt_clear.action = self.bt_clear_action

        self.receive_view = self.view['receive_view']

        self.send_label1 = self.send_view['send_label1']

        self.textv_send_file = self.view['send_view']['textv_send_file']

        self.tv_progress = self.view['receive_view']['tv_progress']
        self.tv_progress.data_source.items = [
            str(x) for x in range(1, self.connect_limit + 1)
        ]
        self.tv_progress.data_source.tableview_cell_for_row = self.tv_progress_cell_for_row
        self.tv_progress.data_source.tableview_delete = self.tv_progress_delete
        self.tv_progress.delegate.tableview_did_select = self.tv_progress_did_select
        self.tv_progress.delegate.tableview_accessory_button_tapped = self.tv_progress_info_btn

        self.tf_password = self.view['send_view']['tf_password']
        self.tf_password.delegate = self.tf_password_Delegate
        self.tf_password.delegate.textfield_did_change = self.tf_password_did_change
        self.tf_password.autocorrection_type = False
        self.tf_password.spellchecking_type = False
        self.tf_password.autocapitalization_type = ui.AUTOCAPITALIZE_NONE
        self.tf_password.text = password

        # making progress cell obj
        self.progress_cell_dict = {}
        for i in range(1, self.connect_limit + 1):
            cell = ui.TableViewCell('subtitle')

            cell_label = ui.Label(frame=(0, 0, ui.get_window_size()[0], 44),
                                  name="label")
            cell_label.alpha = 0.5
            cell_label.width = 0
            cell_label.flex = "WLRTB"
            #cell_label.frame = (0,0,ui.get_window_size()[0] ,44)

            cell.content_view.add_subview(cell_label)
            cell._width = cell.width
            cell.width = 0
            cell.content_view["label"].bg_color = 'yellowgreen'
            cell.text_label.text = 'test'
            self.progress_cell_dict[i] = {}
            self.progress_cell_dict[i]['cell_obj'] = cell
            self.progress_cell_dict[i]['lock'] = threading.Lock()

        self.exit_flag = False
        self.exit_receive_server_flag = False
        self.send_file_list = []

        self.receiver = None
        self.receive_view['label1'].text = 'Save dir {}'.format(self.save_dir)
Beispiel #33
0
 def get_viewpos_from_touch(self, touch):
     xt, yt = touch.location
     xw, yw = ui.get_window_size()
     return xt, yw - yt