Beispiel #1
0
    def group_list_action(self, sender):
        """
		Executes when a list item is selected  in the Group list view.
		"""
        self.selected_group_row = sender.selected_row
        self.root_view.navigation_view.push_view(self.people_pushed_view)
        # add buttons to Nav View
        add_person_btn = ui.ButtonItem('Add', None, self.people_btn_action)
        self.people_pushed_view.right_button_items = [add_person_btn]

        people_list = self.groups_list[self.selected_group_row].get_people()
        people_items = []
        for person in people_list:
            name = person.get_name()
            people_items.append({'title': name})
        # You can use a list or a class as the data source for the tableview
        self.people_listsource = ui.ListDataSource(people_items)
        self.people_table.data_source = self.people_listsource
        self.people_table.delegate = self.people_listsource
        self.people_listsource.edit_action = self.people_edit_action
        self.people_table.reload()
Beispiel #2
0
	def __init__(self, root_node, allow_multi=False, async_mode=False):
		self.async_mode = async_mode
		self.allow_multi = allow_multi
		self.selected_entries = None
		self.table_view = ui.TableView()
		self.table_view.frame = (0, 0, 500, 500)
		self.table_view.data_source = self
		self.table_view.delegate = self
		self.table_view.flex = 'WH'
		self.table_view.allows_multiple_selection = True
		self.table_view.tint_color = 'gray'
		self.view = ui.View(frame=self.table_view.frame)
		self.view.add_subview(self.table_view)
		self.view.name = root_node.title
		self.busy_view = ui.View(frame=self.view.bounds, flex='WH', background_color=(0, 0, 0, 0.35))
		hud = ui.View(frame=(self.view.center.x - 50, self.view.center.y - 50, 100, 100))
		hud.background_color = (0, 0, 0, 0.7)
		hud.corner_radius = 8.0
		hud.flex = 'TLRB'
		spinner = ui.ActivityIndicator()
		spinner.style = ui.ACTIVITY_INDICATOR_STYLE_WHITE_LARGE
		spinner.center = (50, 50)
		spinner.start_animating()
		hud.add_subview(spinner)
		self.busy_view.add_subview(hud)
		self.busy_view.alpha = 0.0
		self.view.add_subview(self.busy_view)
		self.done_btn = ui.ButtonItem(title='Done', action=self.done_action)
		if self.allow_multi:
			self.view.right_button_items = [self.done_btn]
		self.done_btn.enabled = False
		self.root_node = root_node
		self.entries = []
		self.flat_entries = []
		if self.async_mode:
			self.set_busy(True)
			t = threading.Thread(target=self.expand_root)
			t.start()
		else:
			self.expand_root()
Beispiel #3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.update_interval = 1 / 15

        self.hand_id = 0
        self.name = '右手'
        self.change_hand_button = ui.ButtonItem(title='change_hand',
                                                action=self.change_hand)
        self.right_button_items = [self.change_hand_button]

        self.trackpad = trackpad.Trackpad(frame=(0, self.frame.size.height -
                                                 250 - 150, 250, 250),
                                          flex='LRT',
                                          bg_color='blue')
        self.trackpadclicked_switch = ui.Switch(
            frame=(0, self.height - 450, 100, 100),
            flex='LRT',
        )

        self.trigger = ui.Slider(frame=(0, self.height - 150, 100, 30),
                                 flex='LRT')

        self.socketcontroller = socketnetui.controllerUI(flex='RW')
        self.socketcontroller.width = self.width

        self.info_label = ui.Label(flex='W',
                                   scales_font=True,
                                   number_of_lines=0)
        self.info_label.y = 40

        self.arposcontrollui = arpositiontracker.ARTrackerControllerUI(
            flex='WT', bg_color='red')
        self.arposcontrollui.width = self.width

        self.add_subview(self.info_label)
        self.add_subview(self.socketcontroller)
        self.add_subview(self.trackpad)
        self.add_subview(self.trackpadclicked_switch)
        self.add_subview(self.trigger)
        self.add_subview(self.arposcontrollui)
Beispiel #4
0
    def get_condensed_list(self):

        # see https://forum.omz-software.com/topic/2724/spacing-of-buttonitem-s
        i = 0
        x = 0
        btn_container = ui.View(name='test')

        for button_item in self.button_item_list:
            btn = ui.Button(image=button_item.image, action=button_item.action)
            #button_item.action(btn_container)
            width = button_item.image.size[0]
            btn.frame = (x, 0, width, DEFAULT_HEIGHT)
            x = x + width + self.x_spacing
            btn_container.add_subview(btn)
            i = i + 1

        x = x - self.x_spacing
        btn_container.frame = (0, 0, x, DEFAULT_HEIGHT)
        btn_item = ui.ButtonItem()
        btn_item_objc = ObjCInstance(btn_item)
        btn_item_objc.customView = ObjCInstance(btn_container)
        return [btn_item]
Beispiel #5
0
    def __init__(self, **kwargs):
        screen_sz = ui.get_screen_size()
        self.info = ui.load_view('rtorrent')
        self.info['deleteButton'].action = self.on_delete_clicked
        ui.View.__init__(self, *kwargs)

        self.add_view = ui.TableView()

        data = ui.ListDataSource([])
        data.action = self.on_row_picked
        data.delete_enabled = False

        tableview = ui.TableView()
        tableview.flex = 'WH'
        tableview.data_source = data
        tableview.delegate = data
        tableview.allows_selection = True
        data.action = self.on_row_picked

        addButton = ui.ButtonItem(title='+')
        addButton.action = self.on_add_torrent_clicked
        addButton.enabled = True

        self.right_button_items = [addButton]

        nav = ui.NavigationView(tableview)
        self.add_subview(nav)
        nav.add_subview(tableview)
        nav.flex = 'TBWH'
        nav.frame = self.bounds

        self.nav = nav
        self.data = data

        self.mgr = TorrentMgr('')
        self.update()

        self.dropbox = None
        self.torrent_priority = None
Beispiel #6
0
 def setup_main_view(self):
     docsets = self.docset_manager.getDownloadedDocsets()
     cheatsheets = self.cheatsheet_manager.getDownloadedCheatsheets()
     usercontributed = self.usercontributed_manager.getDownloadedUserContributed(
     )
     stackoverflows = self.stackoverflow_manager.getDownloadedStackOverflows(
     )
     main_view = UISearchControllerWrapper.get_view(
         DocsetListView.get_view(docsets, cheatsheets, usercontributed,
                                 stackoverflows,
                                 self.docset_selected_for_viewing,
                                 self.cheatsheet_selected_for_viewing,
                                 self.usercontributed_selected_for_viewing,
                                 self.stackoverflow_selected_for_viewing,
                                 self.theme_manager),
         self.search_all_docsets, self.docset_index_selected_for_viewing,
         self.theme_manager,
         self.build_offline_index_stackoverflow_selected_for_viewing)
     settings_button = ui.ButtonItem(title='Settings')
     settings_button.action = self.show_settings_view
     main_view.left_button_items = [settings_button]
     return main_view
Beispiel #7
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 #8
0
    def create_main_view(self):
        scroll = ui.ScrollView()
        scroll.name = self.APP_NAME
        scroll.width = self.width
        scroll.height = self.height
        scroll.background_color = 'white'
        scroll.content_size = (self.width, self.height)

        scroll.always_bounce_vertical = True
        scroll.always_bounce_horizontal = True

        close = lambda s: self.close()
        btni_close = ui.ButtonItem(title="Close", action=close)
        scroll.left_button_items = [btni_close]

        # btni_settings = ui.ButtonItem(
        #   title='Settings',
        #   action=self.settings_action
        # )
        # scroll.right_button_items = [
        #   btni_settings,
        # ]
        return scroll
Beispiel #9
0
	def did_load(self):
		self.right_button_items = [ui.ButtonItem(image=ui.Image('iob:ios7_reload_32'), action=lambda s: self.restart(prompt=True))]
		self._highscore = highscore.get()
		self._update_title()
		
		self._dice_view = self['dice']
		self._dice_view.onrollfinished = self._handle_roll_finished
		self._dice_view.onholdchange = self._handle_hold_changed
		self._rolling = False
		
		self._roll_btn = self['roll_btn']
		self._roll_btn.action = lambda s: self._roll()	
		self._score_lbl = self['score']
		
		self._sv = self['categories']
		self._top_bonus_lbl = self._sv['top_bonus_slbl']
		self._top_total_lbl = self._sv['top_total_slbl']
		self._bonus_yahtzee_lbl = self._sv['bonus_yahtzee_slbl']
		self._bonus_yahtzee_ticks = self._sv['bonus_yahtzee_ticks']
		self._bot_total_lbl = self._sv['bot_total_slbl']
		
		self._category_buttons = {}
		self._init_score_buttons()
		self._update_views()
Beispiel #10
0
 def __make_biC(self):
     self.__biC = ui.ButtonItem()
     self.__biC.title = 'Cancel'
     self.__biC.action = self.__biCA
     self.left_button_items = [self.__biC]
Beispiel #11
0
        tableview.navigation_view.push_view(webview)

    def tableview_number_of_sections(self, tableview):
        return len(self.dates)

    def tableview_number_of_rows(self, tableview, section):
        return len(self.dates[self.date_indices[section]])

    def tableview_cell_for_row(self, tableview, section, row):
        cell = ui.TableViewCell()
        cell.text_label.text = self.dates[
            self.date_indices[section]][row]['title']
        return cell

    def tableview_title_for_header(self, tableview, section):
        return str(self.date_indices[section])


add_button_item = ui.ButtonItem('Add Feed URL', None, add_feed)

table_view = ui.TableView()
table_view.name = 'Feeds'
table_view.allows_multiple_selection_during_editing = True
table_view.data_source = feed_list_controller
table_view.delegate = feed_list_controller

navigation_view = ui.NavigationView(table_view)
navigation_view.right_button_items = [add_button_item]
navigation_view.name = 'RSS Reader'
navigation_view.present('fullscreen')
Beispiel #12
0
        l.text_color = 'green'
        UIDocumentPickerViewController.view().addSubview_(ObjCInstance(l))

    objc_uiview = ObjCInstance(uiview)
    SUIViewController = ObjCClass('SUIViewController')
    vc = SUIViewController.viewControllerForView_(objc_uiview)
    vc.presentViewController_animated_completion_(
        UIDocumentPickerViewController, True, None)


if __name__ == '__main__':
    # demo code
    mv = ui.View()
    mv.background_color = 'white'
    mv.name = 'Test Save local file to Files without open_in'
    b = ui.ButtonItem()
    b.title = 'save to Files'

    def b_action(sender):
        file = os.path.expanduser('~/Documents/Welcome.md')
        title = 'your title, ex: telling user where he would save'
        #SaveInFiles(file, 600,400, callback=callback, title=title)
        SaveInFiles(file,
                    600,
                    500,
                    callback=callback,
                    title=title,
                    mode='popover',
                    popover_location=(mv.width - 40, 60))

    b.action = b_action
	
def submit_test(sender):
	testtext = post_edit_box.text
	post_edit_box.text = 'testing' + testtext
	
def insert_code():
	return 'Write Something!\n\n<pre><code>\n\n%s\n</code></pre>' % editor.get_text()
	
def markdown_prev(sender):
	mkd_w.load_html(markdown.markdown(post_edit_box.text))
	mkd.present('fullscreen')
	
#UI Code
view = ui.View()
view.background_color = 'white'
markdown_prev = ui.ButtonItem(title='Markdown Preview', action=markdown_prev, enabled=True)
view.right_button_items = [markdown_prev]

#Title Field
title_field = ui.TextField()
title_field.frame = 5,8,600,30
title_field.corner_radius = 5
title_field.bordered = True
title_field.border_color = '#999999'
title_field.border_width = 1
title_field.placeholder = 'Title of Post (Required)'
view.add_subview(title_field)

#Post Type
sc = ui.SegmentedControl()
sc.segments = ['General','Share Code','Question']
Beispiel #14
0
	conn.commit()

	feeds = []
	for title, url in conn.execute('SELECT * FROM feeds ORDER BY title'):
		feeds.append({'title': title, 'url': url })

	conn.close()

	feed_list_controller.feeds = feeds
	table_view.reload()
	indicator.stop()
	navigation_view.remove_subview(indicator)
	

# make view
feed_list_controller = FeedListController(feeds)

add_button_item = ui.ButtonItem('Add Feed URL', None, add_feed)
add_button_item2 = ui.ButtonItem('Edit', None, feed_list_controller.edit_table)

table_view = ui.TableView()
table_view.name = 'Feeds'
table_view.allows_selection_during_editing = True
table_view.data_source = feed_list_controller
table_view.delegate = feed_list_controller

navigation_view = ui.NavigationView(table_view)
navigation_view.right_button_items = [add_button_item]
navigation_view.left_button_items = [add_button_item2]
navigation_view.name = 'RSS Reader'
navigation_view.present('fullscreen') 
        ui.set_color((1.0, 0.4, 0.4, 1.0))
        path.fill()
        path.line_width = 10.0
        ui.set_color((0.8, 1.0, 0.5, 1.0))
        path.stroke()
        ui.draw_string('Label',
                       rect=(50, 175, 400, 100),
                       font=tuple(('Georgia', 20)),
                       color=(0.4, 0.6, 1.0, 1.0),
                       alignment=0,
                       line_break_mode=4)
        ui.Image("Dog_Face").draw(50, 200, 300, 300)
        img = ctx.get_image()
    return img


img = create_image()
#img.show()
main_view = ui.View(frame=(0, 0, 500, 500))
imgview = ui.ImageView(frame=(0, 0, 500, 500))
imgview.image = img
main_view.add_subview(imgview)
save_button = ui.ButtonItem()
save_button.title = 'Save'
save_button.action = save_action
show_button = ui.ButtonItem()
show_button.title = 'Show'
show_button.action = showimage_action
main_view.right_button_items = [save_button, show_button]
main_view.present('sheet')
Beispiel #16
0
    def __init__(self, title, sections, done_button_title='Done', font=None):
        self.was_canceled = True
        #self.was_canceled = False
        self.shield_view = None
        self.values = {}
        self.container_view = _FormContainerView()
        self.container_view.frame = (0, 0, 500, 500)
        self.container_view.delegate = self
        self.view = ui.TableView('grouped')
        self.view.flex = 'WH'
        self.container_view.add_subview(self.view)
        self.container_view.name = title
        self.view.frame = (0, 0, 500, 500)
        self.view.data_source = self
        self.view.delegate = self
        self.cells = []
        self.tf_ramq = 'xxxxxxxxxxxx'

        self.sections = sections

        for section in self.sections:
            section_cells = []
            self.cells.append(section_cells)
            items = section[1]
            for i, item in enumerate(items):
                cell = ui.TableViewCell('value1')
                icon = item.get('icon', None)
                tint_color = item.get('tint_color', None)
                if font:
                    cell.text_label.font = font
                if tint_color:
                    cell.tint_color = tint_color
                if icon:
                    if isinstance(icon, basestring):
                        icon = ui.Image.named(icon)
                    if tint_color:
                        cell.image_view.image = icon.with_rendering_mode(
                            ui.RENDERING_MODE_TEMPLATE)
                    else:
                        cell.image_view.image = icon

                title_color = item.get('title_color', None)
                if title_color:
                    cell.text_label.text_color = title_color

                t = item.get('type', None)
                key = item.get('key', item.get('title', str(i)))
                item['key'] = key
                title = item.get('title', '')
                if t == 'segmented':
                    value = item.get('value', '')
                    self.values[key] = value
                    #bgcolor = 0.9

                    #Set up cell
                    cell.selectable = False
                    cell.text_label.text = title
                    label_width = ui.measure_string(
                        title, font=cell.text_label.font)[0]
                    cell_width, cell_height = cell.content_view.width, cell.content_view.height
                    #cell.background_color= bgcolor

                    #Set up scroll view
                    scroll = ui.ScrollView()
                    scroll_width = max(40, cell_width - label_width - 32)
                    scroll.frame = (cell_width - scroll_width - 8, 1,
                                    scroll_width, cell_height - 2)
                    scroll.flex = 'W'
                    #scroll_width = max(40, cell_width - label_width )
                    #scroll.frame = (cell_width - scroll_width+40, 1, scroll_width, cell_height-2)
                    scroll.shows_horizontal_scroll_indicator = False
                    #scroll.background_color = bgcolor

                    #Set up segment
                    segment = ui.SegmentedControl()
                    choices = item.get('choice', '').split("|")
                    segment.segments = choices
                    if value != '':
                        segment.selected_index = choices.index(value)
                    #segment.value = value
                    segment.name = key
                    segment.action = self.segment_action
                    segment.frame = (0, 0, len(segment.segments) * 65,
                                     scroll.height)

                    #Combining SUBVIEWS
                    scroll.content_size = (len(segment.segments) * 65,
                                           scroll.height)
                    scroll.add_subview(segment)
                    cell.content_view.add_subview(scroll)

                elif t == 'photo':
                    value = item.get('value', False)
                    self.values[key] = value
                    cell.text_label.text = title
                    cell.selectable = False
                    photo_button = ui.Button()
                    photo_button.name = key
                    show_photo = ui.Button()
                    show_photo.name = key
                    label_width = ui.measure_string(
                        title, font=cell.text_label.font)[0]
                    cell_width, cell_height = cell.content_view.width, cell.content_view.height
                    ph_width = max(40, cell_width - label_width - 32)
                    photo_button.frame = (cell_width - ph_width - 8, 1,
                                          ph_width / 3, cell_height - 2)
                    show_photo.frame = (cell_width - ph_width / 2, 1,
                                        ph_width / 2, cell_height - 2)
                    photo_button.flex = 'W'
                    photo_button.background_color = 0.9
                    show_photo.background_color = 0.95
                    photo_button.title = 'Take picture'
                    show_photo.title = 'Show picture'
                    cell.content_view.add_subview(photo_button)
                    cell.content_view.add_subview(show_photo)
                    #photo_button.action = self.take_photo
                    photo_button.action = self.photoBooth
                    show_photo.action = self.photo_quicklook

                elif t == 'switch':
                    value = item.get('value', False)
                    self.values[key] = value
                    cell.text_label.text = title
                    cell.selectable = False
                    switch = ui.Switch()
                    w, h = cell.content_view.width, cell.content_view.height
                    switch.center = (w - switch.width / 2 - 10, h / 2)
                    switch.flex = 'TBL'
                    switch.value = value
                    switch.name = key
                    switch.action = self.switch_action
                    if tint_color:
                        switch.tint_color = tint_color
                    cell.content_view.add_subview(switch)
                elif t == 'text' or t == 'url' or t == 'email' or t == 'password' or t == 'number':
                    value = item.get('value', '')
                    self.values[key] = value
                    placeholder = item.get('placeholder', '')
                    cell.selectable = False
                    cell.text_label.text = title
                    label_width = ui.measure_string(
                        title, font=cell.text_label.font)[0]
                    if cell.image_view.image:
                        label_width += min(64,
                                           cell.image_view.image.size[0] + 16)
                    cell_width, cell_height = cell.content_view.width, cell.content_view.height
                    tf = ui.TextField()

                    tf.name = key
                    if tf.name == 'fname':
                        self.tf_fname = tf
                    if tf.name == 'lname':
                        self.tf_lname = tf
                    if tf.name == 'ramq':
                        self.tf_ramq = tf

                    tf_width = max(40, cell_width - label_width - 32)
                    tf.frame = (cell_width - tf_width - 8, 1, tf_width,
                                cell_height - 2)
                    tf.bordered = False
                    tf.placeholder = placeholder
                    tf.flex = 'W'
                    tf.text = value
                    tf.text_color = '#337097'
                    if t == 'text':
                        tf.autocorrection_type = item.get(
                            'autocorrection', None)
                        tf.autocapitalization_type = item.get(
                            'autocapitalization', ui.AUTOCAPITALIZE_SENTENCES)
                        tf.spellchecking_type = item.get('spellchecking', None)
                    if t == 'url':
                        tf.keyboard_type = ui.KEYBOARD_URL
                        tf.autocapitalization_type = ui.AUTOCAPITALIZE_NONE
                        tf.autocorrection_type = False
                        tf.spellchecking_type = False
                    elif t == 'email':
                        tf.keyboard_type = ui.KEYBOARD_EMAIL
                        tf.autocapitalization_type = ui.AUTOCAPITALIZE_NONE
                        tf.autocorrection_type = False
                        tf.spellchecking_type = False
                    elif t == 'number':
                        tf.keyboard_type = ui.KEYBOARD_NUMBERS
                        tf.autocapitalization_type = ui.AUTOCAPITALIZE_NONE
                        tf.autocorrection_type = False
                        tf.spellchecking_type = False
                    elif t == 'password':
                        tf.secure = True

                    tf.clear_button_mode = 'while_editing'
                    tf.name = key
                    tf.delegate = self
                    cell.content_view.add_subview(tf)

                elif t == 'check':
                    value = item.get('value', False)
                    group = item.get('group', None)
                    if value:
                        cell.accessory_type = 'checkmark'
                        cell.text_label.text_color = cell.tint_color
                    cell.text_label.text = title
                    if group:
                        if value:
                            self.values[group] = key
                    else:
                        self.values[key] = value
                elif t == 'date' or t == 'datetime' or t == 'time':
                    value = item.get('value', datetime.datetime.now())
                    if type(value) == datetime.date:
                        value = datetime.datetime.combine(
                            value, datetime.time())
                    if type(value) == datetime.time:
                        value = datetime.datetime.combine(
                            value, datetime.date.today())
                    date_format = item.get('format', None)
                    if not date_format:
                        if t == 'date':
                            date_format = '%Y-%m-%d'
                        elif t == 'time':
                            date_format = '%H:%M'
                        else:
                            date_format = '%Y-%m-%d %H:%M'
                    item['format'] = date_format
                    cell.detail_text_label.text = value.strftime(date_format)
                    self.values[key] = value
                    self.ramq_dob = ''
                    cell.text_label.text = title
                else:
                    cell.selectable = False
                    cell.text_label.text = item.get('title', '')

                section_cells.append(cell)

        done_button = ui.ButtonItem(title=done_button_title)
        done_button.action = self.done_action
        self.container_view.right_button_items = [done_button]
Beispiel #17
0
        def __init__(self, selected):

            # In multiple selection mode, an "ok" button is needed
            if multiple:
                ok_button = ui.ButtonItem()
                ok_button.title = 'ok'
                ok_button.action = self.ok_button_action
                self.right_button_items = [ok_button]

            # ListDataSource for clients TableView
            elements_lst = ui.ListDataSource(items=lst)
            # ListDataSource has no attribute "name"
            elements_lst.delete_enabled = False
            elements_lst.move_enabled = False
            elements_txt = ui.TableView(name='elements_txt')
            elements_txt.allows_multiple_selection = multiple
            elements_txt.allows_selection = selectable
            elements_txt.text_color = 'black'
            elements_txt.font = ('Courier', 12)
            if elements == grids:
                elements_txt.row_height = back.thumb_size
            else:
                elements_txt.row_height = elements_txt.font[1] * 2
            h = len(lst) * elements_txt.row_height
            font = ImageFont.truetype('Courier', 16)
            w = 0

            if elements == grids:
                ws, hs = ui.get_screen_size()
                w = int(elements_txt.row_height * ws / hs)
                h_ele = elements_txt.row_height
                h_max = h_screen * 0.9
            else:
                for element in lst:
                    w_ele, h_ele = font.getsize(element)
                    if w_ele > w:
                        w = w_ele
                w = w + 32
                h_max = h_screen * 0.8
            elements_txt.content_size = (w, h)
            if h > h_max:
                h = h_max
            w_max = w_screen - 20
            if w > w_max:
                w = w_max
            elements_txt.frame = (4, 4, w, h)
            #elements_txt.border_color = 'blue'
            #elements_txt.border_width = 3
            elements_txt.data_source = elements_lst
            elements_txt.data_source.tableview_cell_for_row = self.tableview_cell_for_row
            if not multiple:
                if selected >= 0:
                    elements_txt.selected_row = (0, selected)
            else:
                if selected_lst != []:
                    elements_txt.selected_rows = selected_lst

            elements_txt.delegate = self
            self.add_subview(elements_txt)
            self.width = elements_txt.width + 8
            self.height = elements_txt.height + 8
            self.corner_radius = 20
            self.border_color = 'blue'
            self.border_width = 2
            self.background_color = color
            if title and multiple:
                # title bar displayed in multiple
                self.name = title
            self.pending = []
colorbtn = ui.Button()
colorbtn.action = color_palette
colorbtn.frame = (buttonWidth, 0, buttonWidth, 50)
colorbtn.image = ui.Image('iob:record_24')
colorbtn.tint_color = "black"
settingsbtn = ui.Button()
settingsbtn.action = more
settingsbtn.frame = (0, 0, buttonWidth, 50)
settingsbtn.image = ui.Image('iow:more_32')
settingsbtn.tint_color = "white"
toolbar.add_subview(clearbtn)
toolbar.add_subview(utensilbtn)
toolbar.add_subview(colorbtn)
toolbar.add_subview(settingsbtn)

sharebtn = ui.ButtonItem()
sharebtn.image = ui.Image('iow:ios7_upload_outline_24')
sharebtn.tint_color = "white"
sharebtn.action = drawCanvas.share_image

if ".png" not in popup["Name"]:
    popup["Name"] += ".png"

root = ui.View()
root.frame = (0, 0, ss[0], ss[1])
root.name = popup["Name"]
root.background_color = '#f5f5f5'

palette = ui.ScrollView()
palette.background_color = "white"
Beispiel #19
0
def make_button_item(action, image_name):
    return ui.ButtonItem(action=action, image=ui.Image.named(image_name))
Beispiel #20
0
    tab_set = set([current_relpath()])

    root_view = ui.View(flex="WH")
    root_view.width = 200
    root_view.border_color = 0.7
    root_view.border_width = 1

    tab_ds = ui.ListDataSource(list(tab_set))
    tab_ds.delete_enabled = True
    tab_ds.move_enabled = True
    tab_ds.action = ds_action

    tab_list = ui.TableView(flex="WH")
    tab_list.data_source = tab_ds
    tab_list.delegate = tab_ds
    tab_list.left_button_items = ui.ButtonItem(title="    ",
                                               action=tb_button_action),
    tab_list.right_button_items = (
        ui.ButtonItem(title="    ", action=tb_button_action),
        ui.ButtonItem(title="Edit", action=tb_button_action),
        ui.ButtonItem(image=ui.Image.named("ionicons-ios7-plus-empty-32"),
                      action=tb_button_action))

    nav = ui.NavigationView(tab_list, flex="WH")
    nav.navigation_bar_hidden = False

    root_view.add_subview(nav)

    root_view.present("sidebar")

    nav.width = root_view.width
    nav.height = root_view.height
Beispiel #21
0
#!python2
# coding: utf-8

# https://forum.omz-software.com/topic/2473/suggestion-ui-left_button_items-and-right-not-be-none-either-a-empty-tuple-or-list-or-a-property-access/2

from __future__ import print_function
import ui

v = ui.View(frame=(0, 0, 500, 500))
btn_l0 = ui.ButtonItem('left0')
btn_r0 = ui.ButtonItem('right0')
v.left_button_items = [btn_l0]
v.right_button_items = [btn_r0]

btns = [(btn, btn.enabled)
        for btn in v.left_button_items + v.right_button_items
        if isinstance(btn, ui.ButtonItem)]
print(btns)
v.present('sheet')
Beispiel #22
0
 def __init__(self,
              root_node,
              icloud_node=None,
              import_file_path=None,
              allow_multi=False,
              async_mode=False):
     self.async_mode = async_mode
     self.allow_multi = allow_multi
     self.import_file_path = import_file_path
     self.multi_input = False
     self.filename = None
     self.selected_entries = None
     self.table_view = ui.TableView()
     self.table_view.frame = (0, 0, 500, 500)
     self.table_view.data_source = self
     self.table_view.delegate = self
     self.table_view.flex = 'WH'
     self.table_view.allows_multiple_selection = allow_multi
     self.table_view.tint_color = 'gray'
     self.view = ui.View(frame=self.table_view.frame)
     self.view.add_subview(self.table_view)
     if self.import_file_path[1:]:
         self.multi_input = True
     else:
         self.filename = os.path.basename(import_file_path[0])
     self.view.name = self.filename if self.filename else 'Choose Location'
     self.busy_view = ui.View(frame=self.view.bounds,
                              flex='WH',
                              background_color=(0, 0, 0, 0.35))
     hud = ui.View(frame=(self.view.center.x - 50, self.view.center.y - 50,
                          100, 100))
     hud.background_color = (0, 0, 0, 0.7)
     hud.corner_radius = 8.0
     hud.flex = 'TLRB'
     spinner = ui.ActivityIndicator()
     spinner.style = ui.ACTIVITY_INDICATOR_STYLE_WHITE_LARGE
     spinner.center = (50, 50)
     spinner.start_animating()
     hud.add_subview(spinner)
     self.busy_view.add_subview(hud)
     self.busy_view.alpha = 0.0
     self.view.add_subview(self.busy_view)
     self.done_btn = ui.ButtonItem(title='Done', action=self.done_action)
     self.Rename_btn = ui.ButtonItem(
         title='Rename',
         image=ui.Image.named('iob:ios7_compose_outline_32'),
         action=self.rename_action)
     if self.multi_input:
         self.view.right_button_items = [self.done_btn]
     else:
         self.view.right_button_items = [self.done_btn, self.Rename_btn]
     self.done_btn.enabled = False
     self.root_node = root_node
     self.icloud_node = icloud_node
     self.entries = []
     self.flat_entries = []
     if self.async_mode:
         self.set_busy(True)
         t = threading.Thread(target=self.expand_root)
         t.start()
     else:
         self.expand_root()
	def setupsnippetslistview(self):
		dbo = snippetlistview(self.snippets, self.snippetselectaction)
		self.snippetslistview = ui.TableView()
		self.snippetslistview.data_source = dbo
		self.snippetslistview.delegate = dbo
		self.snippetslistview.right_button_items = [ui.ButtonItem(image=ui.Image.named('iob:ios7_plus_empty_32'),action=self.addsnippet)]
Beispiel #24
0
from objc_util import *

v = ui.View(frame=(0, 0, 400, 400), name='Demo')
v.background_color = 'white'

btn_images = [
    ui.Image.named(n)
    for n in ['iob:beaker_32', 'iob:beer_32', 'iob:coffee_32']
]
btn_container = ui.View(frame=(0, 0, len(btn_images) * 32, 44))
for i, img in enumerate(btn_images):
    btn = ui.Button(image=img)
    btn.frame = (i * 32, 0, 32, 44)
    btn_container.add_subview(btn)

btn_item = ui.ButtonItem()
btn_item_objc = ObjCInstance(btn_item)
btn_item_objc.customView = ObjCInstance(btn_container)
v.right_button_items = [btn_item]
v.present('sheet')

#==============================

# coding: utf-8
# This file is part of https://github.com/marcus67/rechtschreibung

import ui
from objc_util import *

DEFAULT_X_SPACING = 8
DEFAULT_HEIGHT = 44
Beispiel #25
0
 def will_switch_to_normal_mode(self):
     self.left_button_items = []
     self.right_button_items = [
         ui.ButtonItem('Edit', action=self.edit_button_tapped)
     ]
Beispiel #26
0
        bar = (chipsize * i, select_height - chipsize,
               (chipsize * i) + chipsize, select_height)
        selected_image.paste(c, bar)
    selected_image.show()
    saveit = photos.save_image(selected_image)

    if saveit is True:
        console.hud_alert('Sampled image has been saved')
    elif saveit is False:
        console.hud_alert('Uh oh, not saved')


#Add buttons for all the colors to a scroll view:
scroll_view = ui.ScrollView(frame=(0, 0, 400, 400))
scroll_view.content_size = (0, len(colors) * 80)
for i, c in enumerate(colors):
    r, g, b = c[1]
    color = (float(r / 255.0), float(g / 255.0), float(b / 255.0))
    swatch = ui.Button(frame=(0, i * 80, 400, 80), background_color=color)
    swatch.title = str(c[1])
    swatch.flex = 'w'
    swatch.action = tapped
    scroll_view.add_subview(swatch)
scroll_view.name = 'Random Color Picker'
save_button = ui.ButtonItem()
save_button.title = 'Save'
save_button.action = save_action
save_button.tint_color = 'red'
scroll_view.right_button_items = [save_button]
scroll_view.present('sheet')
Beispiel #27
0
    [0, 5, 0, 9, 0, 0, 0, 0, 4],
    [0, 0, 0, 1, 0, 0, 6, 0, 0],
]

insane = [
    [8, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 3, 6, 0, 0, 0, 0, 0],
    [0, 7, 0, 0, 9, 0, 2, 0, 0],
    [0, 5, 0, 0, 0, 7, 0, 0, 0],
    [0, 0, 0, 0, 4, 5, 7, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 3, 0],
    [0, 0, 1, 0, 0, 0, 0, 6, 8],
    [0, 0, 8, 5, 0, 0, 0, 1, 0],
    [0, 9, 0, 0, 0, 0, 4, 0, 0],
]

board = Board(insane)

play_button = ui.ButtonItem(tint_color='black',
                            image=sfsymbol.SymbolImage('play',
                                                       8,
                                                       weight=sfsymbol.THIN),
                            action=board.play)
root.right_button_items = [
    play_button,
]

root.add_subview(board)

root.present(animated=False)
Beispiel #28
0
    elif player_choice == 'Rock' and computer_choice == 'Paper':
        player_win('Rock', 'crushes', 'paper')

    elif computer_choice == 'Paper' and player_choice == 'Rock':
        player_loss('Paper', 'covers', 'rock')
    elif computer_choice == 'Scissors' and player_choice == 'Paper':
        player_loss('Scissors', 'cut', 'paper')
    elif computer_choice == 'Rock' and player_choice == 'Scissors':
        player_loss('Rock', 'crushes', 'scissors')
    elif computer_choice == 'Rock' and player_choice == 'Paper':
        player_loss('Rock', 'crushes', 'paper')
    else:
        v['game_result'].text = "Whoops! This wasn\'t supposed to happen!"


v = ui.load_view('rps')

stats_button = ui.ButtonItem()
stats_button.title = 'Stats'
stats_button.action = stats

v.present('sheet')

v.right_button_items = [stats_button]
v['Rock'].image = ui.Image.named('PC_Rock').with_rendering_mode(
    ui.RENDERING_MODE_ORIGINAL)
v['Paper'].image = ui.Image.named('Page_With_Curl').with_rendering_mode(
    ui.RENDERING_MODE_ORIGINAL)
v['Scissors'].image = ui.Image.named('Scissors').with_rendering_mode(
    ui.RENDERING_MODE_ORIGINAL)
    def __init__(self, w, h, simulation):
        global map_pin_type, map_pin_color, map_addr_color, map_pin_size, map_pin_radius, map_pin_borderwidth, map_pin_bordercolor, contacts_photos
        self.width = w
        self.height = h
        self.simulation = simulation
        self.contacts = []
        self.points = {}
        contacts_photos = {}

        # bouton for address
        address_button = ui.ButtonItem()
        address_button.title = 'address'
        address_button.tint_color = 'green'
        address_button.action = self.address_button_action

        # bouton for pin type
        pin_type_button = ui.ButtonItem()
        pin_type_button.title = 'pin'
        pin_type_button.tint_color = 'red'
        pin_type_button.action = self.pin_type_button_action

        self.left_button_items = (address_button, pin_type_button)

        # bouton for map type
        map_type_button = ui.ButtonItem()
        map_type_button.title = 'satellite'
        map_type_button.action = self.map_type_button_action

        # bouton for not yet localized
        not_yet_localized_button = ui.ButtonItem()
        not_yet_localized_button.title = ''
        not_yet_localized_button.action = self.not_yet_localized_button_action

        self.right_button_items = (map_type_button, not_yet_localized_button)

        # global settings
        map_pin_type = 1  # 0=pin 1=photo 2=carree 3=ronde
        map_pin_size = 80
        map_pin_color = 0  # 0=red 1=green 2=purple
        map_addr_color = 1  # 0=red 1=green 2=purple
        map_pin_radius = 5
        map_pin_borderwidth = 2
        map_pin_bordercolor = (255, 0, 0)  # red

        # Message Label
        msg = ui.Label(name='msg_label')
        msg.frame = (w / 4, h / 2, w / 2, 28)
        msg.background_color = (0.00, 0.50, 1.00, 0.5)
        msg.bg_color = 'bisque'
        msg.border_width = 2
        msg.text_color = 'black'
        msg.border_color = 'black'

        msg.alignment = ui.ALIGN_CENTER
        msg.font = ('Courier-Bold', 20)
        msg.hidden = True
        self.add_subview(msg)

        # progressbar
        progress_bar = ui.Label(name='progress_bar', flex='')
        progress_bar.background_color = (0.00, 0.50, 1.00, 0.5)
        progress_bar.bg_color = (0.00, 0.50, 1.00, 0.5)
        progress_bar.hidden = True
        self.add_subview(progress_bar)

        # textfield for address
        address_textfield = ui.TextField(name='address_textfield')
        address_textfield.frame = (10, 10, self.width - 20, 32)
        address_textfield.text = ''
        address_textfield.action = self.address_textfield_action
        address_textfield.hidden = True
        self.add_subview(address_textfield)

        # MapView for maps
        x = 0
        y = 0
        w = self.width
        h = self.height
        frame = CGRect(CGPoint(x, y), CGSize(w, h))
        self.mk_map_view_plan = build_mapview(self, frame)
        #print(dir(self.mk_map_view_plan))

        self.not_yet_localized = {}

        ui.delay(self.scan_contacts, 0.1)
Beispiel #30
0
    def __init__(self, app):
        self.app = app

        self.count_apps = 0
        self.count_categorys = 0
        self.count_stars = 0
        self.count_prices = 0
        self.count_totalValue = 0

        self.cfg_runtimes = 0
        self.cfg_notice = 1
        self.cfg_downloadimg = 1
        self.cfg_log = 1

        self.datasize_img = 0
        self.datasize_log = 0
        self.datasize_database = 0

        self.name = "设置"
        self.flex = "WHRLTB"

        self.fontcolor_pastal = "#999999"
        self.fontcolor_deep = "#5a5a5a"
        self.fontcolor_warnning = "#f41414"

        self.closeBtn = ui.ButtonItem()
        self.closeBtn.image = ui.Image.named('iob:close_round_24')
        self.closeBtn.action = self.app.Close_act
        self.left_button_items = [self.closeBtn]

        self.scrollView = ui.ScrollView()

        self.count_titleLabel = ui.Label()
        self.count_tableView = ui.TableView()
        self.countDataSource = CountDataSource(self.app, self)

        self.count_appsLabel = ui.Label()
        self.count_starsLabel = ui.Label()
        self.count_categorysLabel = ui.Label()
        self.count_runtimesLabel = ui.Label()
        self.count_pricesLabel = ui.Label()
        self.count_totalValueLabel = ui.Label()

        self.count_tableView.add_subview(self.count_runtimesLabel)
        self.count_tableView.add_subview(self.count_appsLabel)
        self.count_tableView.add_subview(self.count_starsLabel)
        self.count_tableView.add_subview(self.count_categorysLabel)
        self.count_tableView.add_subview(self.count_pricesLabel)
        self.count_tableView.add_subview(self.count_totalValueLabel)
        self.scrollView.add_subview(self.count_titleLabel)
        self.scrollView.add_subview(self.count_tableView)

        self.setting_titleLabel = ui.Label()
        self.setting_tableView = ui.TableView()
        self.settingDataSource = SettingDataSource(self.app, self)

        self.setting_noticeBtn = ui.Switch()
        self.setting_downloadBtn = ui.Switch()
        self.setting_logBtn = ui.Switch()

        self.setting_tableView.add_subview(self.setting_noticeBtn)
        self.setting_tableView.add_subview(self.setting_downloadBtn)
        self.setting_tableView.add_subview(self.setting_logBtn)
        self.scrollView.add_subview(self.setting_titleLabel)
        self.scrollView.add_subview(self.setting_tableView)

        self.clear_titleLabel = ui.Label()
        self.clear_tableView = ui.TableView()
        self.clearDataSource = ClaerDataSource(self.app, self)

        self.datasize_imgLabel = ui.Label()
        self.datasize_logLabel = ui.Label()
        self.datasize_sumLabel = ui.Label()

        self.clear_tableView.add_subview(self.datasize_imgLabel)
        self.clear_tableView.add_subview(self.datasize_logLabel)
        self.clear_tableView.add_subview(self.datasize_sumLabel)
        self.scrollView.add_subview(self.clear_titleLabel)
        self.scrollView.add_subview(self.clear_tableView)

        self.info_titleLabel = ui.Label()
        self.info_tableView = ui.TableView()
        self.infoDataSource = InfoDataSource(self.app, self)

        self.scrollView.add_subview(self.info_titleLabel)
        self.scrollView.add_subview(self.info_tableView)

        self.copyrightLabel = ui.Label()
        self.scrollView.add_subview(self.copyrightLabel)

        self.add_subview(self.scrollView)

        self.loadData()