Ejemplo n.º 1
0
def load_editor(file_manager=None, file_viewer=ui.View(), frame=(0, 0, 540, 600)): #  575)):
    try:
        view = ui.load_view("HTMLEditor/__init__")
    except ValueError as e:
        print "Attempt 1 'HTMLEditor/__init__' failed " + exception_str(e)
        try:
            view = ui.load_view("__init__")
        except ValueError as e:
            print "Attempt 2 '__init__' failed " + exception_str(e)
            view = ui.Editor()
    view.frame = frame
    view.set_fv_fm(file_manager, file_viewer)
    return view
Ejemplo n.º 2
0
def load_editor_view(frame=None, load_addons=True):
    try:
        view = ui.load_view("EditorView/EditorView")
    except ValueError as e:
        logger.debug("Attempt 1 'EditorView/EditorView' failed")
        logger.exception(exception_str(e))
        try:
            view = ui.load_view("EditorView")
        except ValueError as e:
            logger.debug("Attempt 2 'EditorView' failed")
            logger.exception(exception_str(e))
            view = ui.WebView()
    if frame:
        view.frame = frame
    return view
Ejemplo n.º 3
0
def load_editor(file_manager = None, file_viewer = ui.View(), frame=(0, 0, 540, 575)):
    try:
        view = ui.load_view("ServerEditor/__init__")
    except ValueError as e:
        print "Attempt 1 'ServerEditor/__init__' failed"
        print e
        try:
            view = ui.load_view("__init__")
        except ValueError as e:
            print "Attempt 2 '__init__' failed"
            print e
            view = ui.Editor()
    view.frame = frame
    view.set_fv_fm(file_manager, file_viewer)
    return view
Ejemplo n.º 4
0
 def quit(self, sender):
   def ask_user(sender):	#action method for both buttons (yes and no)
     PopOverView.view_po.close()
     if sender.name == 'yes':
       PopOverView.view_main.close()
   PopOverView.view_po = ui.load_view('po')
   PopOverView.view_po.present('popover',popover_location=(400,400))
Ejemplo n.º 5
0
 def load(cls):
     import os, inspect
     pyui= os.path.abspath(inspect.getfile(inspect.currentframe()))+'ui'
     
     if cls._lastinstance is None:
         cls._lastinstance = ui.load_view(pyui)
     return cls._lastinstance
Ejemplo n.º 6
0
    def initView(self,filename=None):
        '''setup the View.  if filename is omitted, open current file in editor'''
        #print os.path.abspath(__file__)
        #shname=inspect.getfile(inspect.getouterframes(inspect.currentframe())[-1])

        p= os.path.dirname(inspect.stack()[-1][1])
        s=  os.path.join(p,os.path.splitext(__file__)[0])
        e=ui.load_view(s)
        # e=ui.load_view(os.path.splitext(__file__)[0])
        e['loadbutton'].action=self.edopen
        e['savebutton'].action=self.edsave
        e['selectbutton'].action=self.edselect

        srcname='editarea.html'
        w=e['webview1']
        w.load_url(os.path.abspath(srcname))

        e.present('panel')
        if filename is not None:
            f=e['filename']
            try:
                f.text=filename
                ui.delay(partial( self.edopen,w), 1)
            except:
                pass
        return e
Ejemplo n.º 7
0
    def prompt_save(self, sender):
        """Prompt the user for the name of a task file."""

        self.save_dialog = ui.load_view("dialogs/save_task_file")
        self.save_dialog["txt_save_file"].begin_editing()
        self.save_dialog["txt_save_file"].delegate = self
        self.save_dialog.present("popover", popover_location=(500, 500))
Ejemplo n.º 8
0
    def prompt_modify_task_number(self, sender):
        """Prompt the user for the number of the task to modify."""

        self.modify_dialog = ui.load_view("dialogs/modify_task_number")
        self.modify_dialog["txt_mod_task_num"].begin_editing()
        self.modify_dialog["txt_mod_task_num"].delegate = self
        self.modify_dialog.present("popover", popover_location=(500, 500))
Ejemplo n.º 9
0
    def prompt_delete_task(self, sender):
        """Prompt the user to delete a task."""

        self.delete_dialog = ui.load_view("dialogs/delete_task")
        self.delete_dialog["txt_del_task"].begin_editing()
        self.delete_dialog["txt_del_task"].delegate = self
        self.delete_dialog.present("popover", popover_location=(500, 500))
Ejemplo n.º 10
0
 def hexview_a_file(self, filename):
     self.view_po = ui.load_view('hexview')
     self.view_po.name = 'HexViewer: ' + filename
     self.view_po.present('full_screen')
     self.view_po['btn_search'].action = self.button_action
     full_pathname = self.path + '/' + filename
     self.view_po['tv_data'].text = hex_view(full_pathname)
Ejemplo n.º 11
0
  def __init__(self, Test = False):
    """
    The class initialise function that sets up the view and handles test conditions if requested
    Arguments:
    Specifics:
    """
    global CAMPAIGN_DATA_DIRECTORY
    global CAMPAIGN_LOG_SELECTED, CAMPAIGN_ASSETS_SELECTED, CAMPAIGN_NOTES_SELECTED
    CAMPAIGN_DATA_DIRECTORY = '/Data/Campaigns/'

    try:
      strCampaignManagementViewName = 'Campaign Management'
      self.vwInterface = ui.load_view(strCampaignManagementViewName)
      self.vwInterface.name = strCampaignManagementViewName
      self.objCampaignData = clsCampaign.clsCampaign()
      self._SelectedLogEntry = -1
      
      self._initialise_campaign_interface()
      self._initialise_control_handlers()
      
      self.vwInterface['tblCampaigns'].data_source.items = os.listdir(os.getcwdu() + CAMPAIGN_DATA_DIRECTORY)
      
      if Test:
        #self.objCampaignData = initialise_test_data()
        #self.objCampaignData.save('xml', CampaignDataDirectory = CAMPAIGN_DATA_DIRECTORY)
        pass

    except:
      pass
Ejemplo n.º 12
0
 def __init__(self):
     self.view = ui.load_view('FileManager')
     self.root = os.path.expanduser('~')
     self.rootlen = len(self.root)
     self.path = os.getcwd()
     self.path_po = self.path
     self.view.name = self.path[self.rootlen:]
     self.tableview1 = self.make_tableview1()
     self.lst = self.make_lst()
     self.lst_po = self.lst
     self.filename = ''
     self.view['btn_Rename'].action = self.btn_Rename
     self.view['btn_Copy'].action = self.btn_Copy
     self.view['btn_Move'].action = self.btn_Move
     self.view['btn_MakeDir'].action = self.btn_MakeDir
     self.view['btn_Delete'].action = self.btn_Delete
     self.view['btn_RemoveDir'].action = self.btn_RemoveDir
     self.view['btn_OpenIn'].action = self.btn_OpenIn
     self.view['btn_Download'].action = self.btn_Download
     self.view['btn_Compress'].action = self.btn_Compress
     self.view['btn_Extract'].action = self.btn_Extract
     self.view['btn_HexView'].action = self.btn_HexView
     self.view['btn_GetPic'].action = self.btn_GetPic #from CameraRoll
     self.view['btn_Settings'].action = self.btn_Settings
     self.view['btn_Help'].action = self.btn_Help
     self.view.present('full_screen')
Ejemplo n.º 13
0
    def __init__(self):
        self.view_names = ['switchview1', 'SwitchViews']
        self.view_index = -1
        self.view_array = []
        
        # load and hide views
        for i in range(len(self.view_names)):
            self.view_index += 1
            self.view_array.append(ui.load_view(self.view_names[self.view_index]))
            self.add_subview(self.view_array[self.view_index])
            self.view_array[self.view_index].hidden = True
        
        # initialize some actions
        self.view_array[0]['btn_Okay'].action = self.all_action
        self.view_array[0]['btn_Cancel'].action = self.all_action
        self.view_array[1]['button1'].action = self.all_action
        
        # show empty white view
        self.background_color = 'white'
        back.action = self.bt_back
        forward.action = self.bt_forward
        self.left_button_items = [space, back]
        self.right_button_items = [space, space, forward]
        self.present()

        # show view 'SwitchViews'
        self.switch_views()
Ejemplo n.º 14
0
def showsidebar():
    """show the sidebar. """
    import ui
    v=ui.load_view('editmenu')
    uncom = v['uncomment']
    uncom.transform = ui.Transform.rotation(pi)
    v.present('sidebar')
Ejemplo n.º 15
0
	def create_cell_contents(self):
		cust_cell = ui.load_view('mycell1')
		self.add_subview(cust_cell)
		cust_cell['lb'].text = str(time.time())
		cust_cell['img1'].image = rand_image()
		
		cust_cell['img2'].image = rand_image()
Ejemplo n.º 16
0
def load_console(frame=(0, 0, 540, 575), load_addons=True):
    try:
        view = ui.load_view("EditorView/EditorViewConsole")
    except ValueError as e:
        logger.error("Attempt 1 'EditorView/EditorViewConsole' failed")
        logger.exception(exception_str(e))
        try:
            view = ui.load_view("EditorViewConsole")
        except ValueError as e:
            logger.error("Attempt 2 'EditorViewConsole' failed")
            logger.exception(exception_str(e))
            view = WebViewConsole()
    logger.debug("Setting Frame")
    view.frame = frame
    logger.debug("Done")
    return view
Ejemplo n.º 17
0
	def __init__(self):
		self.view = ui.load_view('SpecialButton')
		self.view.present('fullscreen')
		self.label = ui.Label(frame=(120,100,100,100))
		self.btn = MyButtonClass(self.label)
		self.view.add_subview(self.btn)		#watch the order, first button and then the label
		self.view.add_subview(self.label)
Ejemplo n.º 18
0
	def __init__(self):
		view = ui.load_view()
		
		# Set announce duration to a default of once per every 15 minutes.
		#view['rootview']['announceFreqTextfield'].text = '15'
		#view['rootview']['announceFreqSlider'].value = .25 # every 1/4 hour.
		
		# cache away the current location (if location services on for Pythonista)
		self.locationString = self.createCurrentLocationString()
		
		if traceFlag: print 'location string in __init__ is ->>' + self.locationString
		
		webview = view['rootview']['webview']

		# Place the analog clock in a location that is sensible for a "gadget"
		# and disable touch or multitouch gestures to prevent unwannted resizing
		# or movement to the underlying clock itself which has no need to do so.
		webview.height = 20
		webview.width = 10
		webview.frame= 15,25,120,125
		webview.multitouch_enabled = False
		webview.touch_enabled = False
		if traceFlag: print 'Presenting view now.'
		view.present('sidebar')
		if traceFlag: print 'Loading html with embedded svg now.'
		webview.load_html(svgInHtml)
Ejemplo n.º 19
0
def showPopupButton(title, handler, yPos):
	v = ui.load_view('popoverButton')
	v['button'].title = title
	v['button'].action = handler
	xPos = 990
	yPos = yPos + 75
	v.height = 6
	v.present('popover', popover_location=(xPos,yPos), hide_title_bar=True)
Ejemplo n.º 20
0
    def prompt_add(self, sender):
        """Prompt the user to add a task."""

        self.add_dialog = ui.load_view("dialogs/add_task")
        self.add_dialog["button_save"].enabled = False
        self.add_dialog["txt_add_task"].delegate = self
        self.add_dialog["txt_add_task"].begin_editing()
        self.add_dialog.present("popover", popover_location=(500, 500))
Ejemplo n.º 21
0
	def setup(self):
		"""
		This extracts saved (persistence) data from pickle files.
		Then it creates all the different Views ready to be called.
		And then it creates the initial user interface.
		"""
		# IMPLEMENT PERSISTANCE
		# Open saved file and extract Group objects.
		# THIS MUST BE CALLED BEFORE THE TABLE ITEMS ARE EXTRACTED!!
		# File path is hard coded for iOS version).
		# This creates a 'generator'.
		saved_items = self.read_file('ios_persistance.pkl')
		# Iterate through saved_items generator and add the contents to the
		# groups_list.
		for item in saved_items:
			self.groups_list.append(item)
		# Do the same for Settings
		# This is a slight duplicate of code but self.read_file didn't quite work.
		if os.path.isfile('settings.pkl'):
			with open('settings.pkl', 'rb') as output:
				self.settings = pickle.load(output)
			
		# SETUP ROOT VIEW (Groups)
		self.root_view = ui.View()
		self.root_view.name = 'Groups'
		self.root_view.background_color = 'white'
		self.root_table = ui.TableView()
		self.root_table.flex = 'WH'
		# Define content items list
		table_items = []
		# Extract items from groups_list
		for group in self.groups_list:
			group_name = group.get_name()
			table_items.append({
				'title': group_name,
				'accessory_type': 'detail_disclosure_button'})
		self.groups_listsource = ui.ListDataSource(table_items)
		self.root_table.data_source = self.groups_listsource
		self.root_table.delegate = self.groups_listsource
		self.groups_listsource.action = self.group_list_action
		self.groups_listsource.edit_action = self.groups_edit_action
		self.groups_listsource.accessory_action = self.group_accessory_action
		self.root_view.add_subview(self.root_table)
		
		# SETUP PEOPLE VIEW
		self.people_pushed_view = ui.load_view('people_view')
		self.people_table = self.people_pushed_view['tableview1']
		
		# IMPLEMENT UI
		# Create button objects with the format
		edit_group_btn = ui.ButtonItem('Settings', None, self.groups_btn_action)
		add_group_btn = ui.ButtonItem('Add', None, self.groups_btn_action)
		# Apply buttons to view
		self.root_view.left_button_items = [edit_group_btn]
		self.root_view.right_button_items = [add_group_btn]
		# Create and present NavigationView
		nav_view = ui.NavigationView(self.root_view)
		nav_view.present()
Ejemplo n.º 22
0
 def btn_Move(self, sender):
     self.view_po = ui.load_view('browse')
     self.view_po.name = self.path_po[self.rootlen:]
     self.view_po.present('popover',popover_location=(self.view.width/2,self.view.height/2))
     self.view_po['btn_Okay'].action = self.btn_Move_Okay
     self.view_po['btn_Cancel'].action = self.btn_Cancel
     self.path_po = self.path
     self.make_lst_po()
     self.view_po['tableview1'].reload()
Ejemplo n.º 23
0
 def bt_local_mkdir(self, sender):
   self.view_po = ui.load_view('popover')
   self.view_po.name = 'Make Directory'
   self.view_po['lb_old_name'].hidden = True 
   self.view_po['lb_on'].hidden = True
   self.view_po.present('popover',popover_location=(self.view.width/2,self.view.height/2))
   self.view_po['lb_nn'].text = 'New Dir:'
   self.view_po['bt_cancel'].action = self.bt_cancel
   self.view_po['bt_okay'].action = self.bt_local_mkdir_okay
Ejemplo n.º 24
0
	def __init__(self):
		self.view = ui.load_view('view_lock.pyui')
		self.passphrase = 'passphrase'
		self.allowed_tries = 8
		self.tries_left = 8
		self.reset_timeout_start = 30
		self.timeout_start = 30
		self.timeout_multiplier = 2
		self.unlock_callback = None
Ejemplo n.º 25
0
	def __init__(self):
		self.view = ui.load_view('check_wrangler')
		self.view.present('fullscreen')
		self.view.name = 'ShowTableView'
		self.currentQuery = ""
		self.myQueue = Queue.Queue() # http://lonelycode.com/2011/02/04/python-threading-and-queues-and-why-its-awesome/
		atexit.register(self.exit_handler)
		self.view['webview1'].load_url('http://google.com')
		self.check_for_new(None)
Ejemplo n.º 26
0
def run():
    global root
    global ctrl
    global out
    root = ui.load_view()
    ctrl = root["ctrl"]
    out = root["out"]
    ctrl.delegate = KBControlDelegate()
    
    root.present("sheet")
Ejemplo n.º 27
0
 def btn_Rename(self, sender):
     self.view_po = ui.load_view('popover')
     self.view_po.name = 'Rename'
     self.view_po.present('popover',popover_location=(self.view.width/2,self.view.height/2))
     self.view_po['label1'].text = 'Old Name:'
     self.view_po['label2'].text = 'New Name:'
     self.view_po['label3'].text = self.filename
     self.view_po['textfield1'].text = self.filename
     self.view_po['btn_Okay'].action = self.btn_Rename_Okay
     self.view_po['btn_Cancel'].action = self.btn_Cancel
Ejemplo n.º 28
0
 def bt_local_rename(self, sender):
   pos = self.localFile.rfind('/')
   self.fileName = self.localFile[pos+1:]
   self.view_po = ui.load_view('popover')
   self.view_po.name = 'Rename'
   self.view_po.present('popover',popover_location=(self.view.width/2,self.view.height/2))
   self.view_po['lb_old_name'].text = self.fileName
   self.view_po['tf_new_name'].text = self.fileName
   self.view_po['bt_okay'].action = self.bt_local_rename_okay
   self.view_po['bt_cancel'].action = self.bt_cancel
Ejemplo n.º 29
0
def showPopupInputAlert(title, handler, text, yPos):
	v = ui.load_view('popoverInputAlert')
	v['label'].text = title
	v['buttonOK'].action = handler
	xPos = 990
	yPos = yPos + 84
	v['textfield'].text = text
	v['textfield'].begin_editing()
	v.height = 90
	v.present('popover', popover_location=(xPos,yPos), hide_title_bar=True)
Ejemplo n.º 30
0
 def btn_MakeDir(self, sender):
     self.view_po = ui.load_view('popover')
     self.view_po.name = 'Delete'
     self.view_po.present('popover',popover_location=(self.view.width/2,self.view.height/2))
     self.view_po['label1'].hidden = True
     self.view_po['label2'].text = 'New Dir:'
     self.view_po['label3'].hidden = True
     self.view_po['textfield1'].text = ''
     self.view_po['btn_Okay'].action = self.btn_MakeDir_Okay
     self.view_po['btn_Cancel'].action = self.btn_Cancel
Ejemplo n.º 31
0
def mpv(url='', page=0):
    view = ui.load_view(pyui_path='gui/mpv.pyui')
    view.xdid_load(url, page=page)
    view.present('fullscreen', hide_title_bar=True, animated=False)
Ejemplo n.º 32
0
                                  ctxId=ch,
                                  color=(ch, 0.00, 1.00),
                                  name='%s' % get_func(ch + 1)[0])
                else:
                    logger.debug('no curv for ch:%s' % ch)
                grph.draw(autoscale=True, ctxId=ch)
        else:
            logger.debug('no chart result')


##****** main ******##
logger = tls.get_logger(__file__, logging.DEBUG)

actPage = None

vseti = ui.load_view('uiSettings.pyui')
vrslt = ui.load_view('uiResults.pyui')
vchart = ui.load_view('uiChart.pyui')
vmain = ui.load_view()

show_page(0, (vseti, vrslt, vchart))

if min(ui.get_screen_size()) >= 768:  # iPad
    vmain.frame = (0, 0, 500, 600)
    vmain.present('sheet')
else:  # iPhone
    vmain.present(orientations=['portrait'])

time.sleep(60)
logger.warning('bye')
Ejemplo n.º 33
0
        self.set_url()
        self['controlpanel']['reload'].hidden = True

    def textfield_did_end_editing(self, textfield):
        self.addressbar_is_editing = False
        self['controlpanel']['reload'].hidden = False
        self.set_url()

    def textfield_should_return(self, textfield):
        url = self['controlpanel']['addressbar'].text
        self.load_url(url)
        textfield.end_editing()
        return True

    def webview_did_start_load(self, webview):
        self.webpage_has_loaded = False

    def webview_did_finish_load(self, webview):
        if not self.addressbar_is_editing:
            self.set_url()
            self.webpage_has_loaded = True
        page_is_bookmarked = unicode(self.get_url()) in self.bookmarks.values()
        self['controlpanel']['favourite'].image = self.favourite_images[
            page_is_bookmarked]
        self.save_history()


view = 'ipad' if ui.get_screen_size()[0] >= 768 else 'iphone'
browser = ui.load_view(view)
browser.present(hide_title_bar=True, style='panel')
Ejemplo n.º 34
0
def button1Click(sender):
    v = ui.load_view('testecris')
    v.present('sheet')
Ejemplo n.º 35
0
def showViewWithData(model):
	v=__setupUi(ui.load_view(),model)
	return v
Ejemplo n.º 36
0
    sender.title = "V-Xing!"
    global_prevValues["xButton_prevBkGrnd_color"] = sender.background_color
    sender.background_color = "#2bacff"
  else:
    sender.title = "VX"
    sender.background_color = global_prevValues["xButton_prevBkGrnd_color"]


            
def listButton_tapped(sender):
  # List the  wave files in the various directories that are available.
  playClickSound()
  if sender.name == "listOriginalButton" :
    v['recordingsView'].text = originalVoices()
  elif sender.name == "listVoicesButton" :
    v['recordingsView'].text = voices2Emulate() 
  else :
    v['recordingsView'].text = XformedVoices()
  


v = ui.load_view('VXgui.pyui')
#v['xButton'].font = ("Times New Roman", 50) 
v.name = 'Voice X-former' # program title
v.background_color = "#e0e0e0" #(0.0, 1.0, 0.0, 1.0) # (r, g, b, alpha)
v.present('fullscreen')




Ejemplo n.º 37
0
    with open('Files/main_text.txt', 'r') as infile:
        main['view1']['textview1'].text = infile.read()
    main['textview1']


def create_r_buttonItems(*buttons):
    items = []
    for b in buttons:
        b = ui.ButtonItem(b)
        b.tint_color = 'white'
        items.append(b)
    return items


# Setup
welcome = ui.load_view('Views/welcome')
main = ui.load_view('Views/main')
im_view = welcome['imageview1']
im_view.image = ui.Image().named('Images/logo.PNG')
sheet = ui.load_view('Views/sheet')
sheet.tint_color = 'white'
with open('Files/agenda.txt', 'r') as infile:
    sheet['textview1'].text = infile.read()
sheet.right_button_items = create_r_buttonItems('>')
welcome.present(hide_title_bar=True)
btn = welcome['button1']
btn.action = show_sheet
sheet.right_button_items[0].action = open_main

# All code above this line is pretty much all that was needed to make this GUI function. This code is intentionally long-winded for clarity.
Ejemplo n.º 38
0
 def __init__(self):
     self.view = ui.load_view('ShowTableView')
     self.view.present('fullscreen')
     self.view.name = 'ShowTableView'
     self.bt_empty_action(None)
Ejemplo n.º 39
0
# coding: utf-8

# https://forum.omz-software.com/topic/3520/gives-an-error-at-the-line-that-i-marked

import ui
import appex
import Image


v = ui.load_view()
#img = appex.get_image()
#if img:
	#v["image"].image = ui.Image(str(img)) #Error occurs here, it says IOError couldn't display image or something like that
img_data = appex.get_image_data()
if img_data:
	v['image'].image = ui.Image.from_data(img_data)
# ...
v.present('sheet')
if not img:
	v.close()

Ejemplo n.º 40
0
            spell = self.magic.do_magic(mybytes, self.iter)
            self.txv_spell.text = spell
        else:
            self.txv_spell.text = ''

    def btn_secret_push(self, sender):
        tmpsecret = self.secret
        if tmpsecret is None:
            tmpsecret = ''
        tmpsecret = dialogs.text_dialog(
            title='Set secret',
            text=tmpsecret,
            autocorrection=False,
            autocapitalization=ui.AUTOCAPITALIZE_NONE,
            spellchecking=False)
        if tmpsecret is None:
            return
        tmpsecret = tmpsecret.strip()
        if tmpsecret:
            keychain.set_password(appname, appname, tmpsecret)
            self.secret = tmpsecret
            self.activate_button()
        else:
            keychain.delete_password(appname, appname)
            self.secret = None
            self.deactivate_button()


gui = ui.load_view(appname)
gui.mypresent()
Ejemplo n.º 41
0
    #Escape HTML
def format_text(text):
    text = text.replace('"', '"', 15)
    text = text.replace('&', '&', 15)
    text = text.replace(''', '', 15)
    text = text.replace('°', '°')
    text = text.replace('ë', 'ë')
    text = text.replace('ü', 'ü')
    text = text.replace('É', 'É')
    text = text.replace('é', 'é')
    text = text.replace('ó', 'ó')
    text = text.replace('²', '²')
    return text


v = ui.load_view('Trivia')
v.present('sheet')


def askQuestion():
    global v
    v['questionBox'].text = question
    v['optionA'].text = options[0]
    v['optionB'].text = options[1]
    v['optionC'].text = options[2]
    v['optionD'].text = options[3]


#Download JSON data
url = 'https://www.opentdb.com/api.php?amount=10&type=multiple'
Ejemplo n.º 42
0
    def tableview_can_delete(self, tableview, section, row):
        return False

    def tableview_can_move(self, tableview, section, row):
        return False

    def tableview_delete(self, tableview, section, row):
        pass

    def tableview_move_row(self, tableview, from_section, from_row, to_section,
                           to_row):
        pass


v = ui.load_view('Garfield')
views = v['scrollview1'].subviews
image_view = views[0]
prev_button = views[1]
next_button = views[2]
share_button = views[3]
date_label = views[4]
table_view = views[5]

image_view.content_mode = ui.CONTENT_SCALE_ASPECT_FIT
table_view.delegate = TableViewDelegate()

indicator = ui.ActivityIndicator()
indicator.style = ui.ACTIVITY_INDICATOR_STYLE_WHITE_LARGE
indicator.background_color = (0.0, 0.0, 0.0, 0.5)
indicator.x = (ui.get_screen_size()[0] - 60) / 2
        console.hud_alert("認識できませんでした。", "error", 0.3)


def run_search():
    v['imageview1'].image = ui.Image('./src/logo.png')
    now = datetime.datetime.now()
    strnow = now.strftime('%H:%M:%S')
    v['nowtime'].text = strnow

    uitime = v['datepicker'].date
    minutes = uitime.strftime('%M')
    iminutes = int(minutes)
    if 0 < iminutes < 30:
        v['datepicker'].date = v['datepicker'].date + datetime.timedelta(
            minutes=30 - iminutes)
    elif 30 < iminutes < 60:
        v['datepicker'].date = v['datepicker'].date + datetime.timedelta(
            minutes=60 - iminutes)

    if keyboard.is_keyboard() == True:
        keyboard.set_view(v)
    else:
        v.present('sheet')


strp = platform.platform()
if strp.count("iPhone") > 0:
    v = ui.load_view('./src/searchg_iphone.pyui')
else:
    v = ui.load_view('./src/searchg.pyui')
Ejemplo n.º 44
0
		sys.exit('Camera roll is empty.')
		
	# Where any photos selected?
	try:
		count = len(assets)
	except TypeError:
		sys.exit('No photos selected.')
		
	# Default pic sizes
	fifty = False
	custom = False
	none = False
	ok = False
	
	# Load pyui files
	v = ui.load_view('PhotosToDropbox')
	v2 = ui.load_view('PhotosToScale')
	
	meta = v['toggle_meta']
	geo = v['toggle_geotag']
	
	# Display ui locked in portrait orientation and wait till user makes choices or quits.
	v.present(orientations = ['portrait'])
	v.wait_modal()
	
	# Get user option choices for keeping metadata and geo_tagging photos
	meta = meta.value
	geo = geo.value
	dest_dir = v['photo_dir'].text
	
	# Go with default if textbox is blank
Ejemplo n.º 45
0
    b = v['slider3'].value
    # Create the new color from the slider values:
    v['view1'].background_color = (r, g, b)
    v['label1'].text = '#%.02X%.02X%.02X' % (int(r * 255), int(
        g * 255), int(b * 255))


def copy_action(sender):
    clipboard.set(sender.superview['label1'].text)
    hud_alert('Copied')


def shuffle_action(sender):
    v = sender.superview
    s1 = v['slider1']
    s2 = v['slider2']
    s3 = v['slider3']
    s1.value = random()
    s2.value = random()
    s3.value = random()
    slider_action(s1)


v = ui.load_view('ColorMixer')
slider_action(v['slider1'])
if ui.get_screen_size()[1] >= 768:
    # iPad
    v.present('sheet')
else:
    # iPhone
    v.present()
Ejemplo n.º 46
0

def close(sender):
    window.close()


views = [
    None, 'iPad_infoPage', 'iPhone_list', 'ipad_codeEditor', 'iPad_envelopes'
]
item = 4

#images
a = ui.Image().named('iob:ios7_contact_outline_256')
x = ui.Image().named('iob:ios7_close_256')
person = ui.Image.named('iob:ios7_people_256')
envelope = ui.Image().named('iob:email_256')
window = ui.load_view(views[item])

#iPhone_list
try:
    scroll = window['scrollview']
    for x in scroll.subviews:
        x['imageview1'].image = a
except:
    None

window.present(hide_title_bar=True, orientations=['portrait'])

#ui.View now supports setting arbitrary attributes, so you don't have to subclass in order to attach some auxiliary data to a view (or any subclass of ui.View). Note that this might hide bugs/typos in your code because something like my_view.fame = ... (instead of my_view.frame) no longer throws an exception (but this is consistent with the way most objects in Python work).

#The UI editor now supports setting custom attributes for views. You can use this to attach arbitrary data to a view or to set built-in attributes that aren't supported directly in the UI editor's inspector (e.g. ui.TextField.keyboard_type).
Ejemplo n.º 47
0
import ui


def button1Click(sender):
    v = ui.load_view('testecris')
    v.present('sheet')


v = ui.load_view('mainmenu')
v.present('sheet')
Ejemplo n.º 48
0
# coding: utf-8

# https://forum.omz-software.com/topic/1338/reminders-list-index-out-of-range/14

import dialogs
import reminders
import ui

v = ui.load_view('reminders')
reminders_table = v['reminders']

def picked(sender):
    item = sender.items[sender.selected_row]
    r = item['reminder']
    r.completed = True
    r.save()
    del sender.items[sender.selected_row]

def grabbed():
    global todo_items, completed_items
    todo = reminders.get_reminders(completed=False)
    todo_items = [{'title': r.title, 'reminder': r} for r in todo]
    done = reminders.get_reminders(completed=True)
    completed_items = [{'title': r.title, 'reminder': r} for r in done]
    reminders_table.data_source = ui.ListDataSource(items=todo_items)
    reminders_table.data_source.action = picked
    reminders_table.reload()

def button_action(sender):
    if segment.selected_index == 0:
        reminders_table.data_source = ui.ListDataSource(items=todo_items)
Ejemplo n.º 49
0
# coding: utf-8

import ui

view = ui.load_view('segmented-control')


def button_action(sender):
    if button1.selected_index == 0:
        view['text_label'].text = 'Hello'
    elif button1.selected_index == 1:
        view['text_label'].text = 'World'


button1 = view['segmentedcontrol1']
button1.action = button_action

view.present('sheet')
Ejemplo n.º 50
0
def pick_your_weather():
    city_typed_in = st = zcode = ''
    lat = lon = 0
    lst = []

    global btn_weather, btn_type, city_picked, city_st, err, item

    btn_weather = btn_type = city_picked = False
    city_st = err = item = ''

    def get_city_list(filename='cities.txt'):
        try:
            with open(filename) as f:
                # Read each line and store in list
                cities = [row for row in csv.reader(f)]
            return cities
        except IOError as e:
            err = 'IOError in city_list(): {}'.format(e)
            console.hud_alert('{}'.format(e), 'error')
            sys.exit(err)
        if not cities:
            err = 'No cities found in {}'.format(filename)
            console.hud_alert(err, 'error')
            sys.exit(err)

    def get_current_lat_lon():
        # Retrieve lat & lon from current locale
        location.start_updates()
        # Delay sometimes improves accuracy
        #time.sleep(1)
        address_dict = location.get_location()
        location.stop_updates()
        return address_dict['latitude'], address_dict['longitude']

    # 'From Where You Are' button tapped
    def btn_weather_tapped(sender):
        global btn_weather
        btn_weather = True
        v.close()

    # City in list was tapped
    def item_selected(sender):
        global city_picked
        city_picked = True
        v.close()

    # Delete slider in TableView cell for a city in list was tapped
    def item_delete(sender):
        global item

        # Thanks to @Phuket2 for help and direction on capturing a delete event in a tableview
        removed = [x for x in items if x not in sender.items]
        if len(removed) == 1:
            item = removed[0]
            #print  'Item {} removed'.format(item)
            items.remove(item)
            console.hud_alert('Removing {} from list of cities.'.format(item))
            item = '{},{}'.format(item[:item.find(',').strip()],
                                  item[item.find(',') + 1:].strip())
            update_city_list('remove', item)
            console.hud_alert('Done')
        else:
            print 'Something wtong, more than 1 removed item'

    # 'From A City You Can Add To List' button was tapped
    def btn_type_tapped(sender):
        global btn_type, city_st, err

        try:
            city_st = dialogs.input_alert('Enter A City, ST:')
            if city_st:
                if not ',' in city_st:
                    err = 'Formatting error'
                    city_st = ''
                    pass
                elif len(city_st.strip()) < 4:
                    err = 'Unlikely city name.'
                    city_st = ''
                    pass
                else:
                    btn_type = True
                    v.close()
                    pass
            else:
                err = 'Nothing Entered'
            if err:
                console.hud_alert(err, 'error')
                err = ''
                pass
        except KeyboardInterrupt:
            pass

    # Create a list for TableView data source
    cities = get_city_list()
    for city in cities:
        # Append city name and state or country to list
        lst.append('{}, {}'.format(city[0], city[1]))

    # Quick and dirty list dialog with limited options
    #x = dialogs.list_dialog(title = 'Pick Your Desired City:', items = lst)

    items = lst
    data_source = ui.ListDataSource(items)
    data_source.delete_enabled = True
    data_source.edit_action = item_delete
    data_source.action = item_selected

    # Load pypi file and reference objects in form
    v = ui.load_view('WeatherAnywhere')
    v.background_color = 'orange'
    tv = v['tv']
    tv.data_source = data_source
    tv.delegate = data_source

    #button_go = v['btn_go']
    #button_go.delegate = ui.Button(button_go)

    #city_st = v['txt_city']
    #city_st.delegate = ui.TextView(city_st).text

    v.present()
    v.wait_modal()

    # Returns a tuple of selected cell's section & row in tableview
    row = tv.selected_row

    # 'From Where You Are' button tapped
    if btn_weather:
        console.hud_alert('Gathering weather data from where you are...',
                          'success', 1)
        # Get lat & lon of where you are
        lat, lon = get_current_lat_lon()

    # A city and state was typed in
    if len(city_st) != 0:
        city_st = city_st.split(',')
        city_typed_in = city_st[0].replace(' ', '%20').strip()
        st = city_st[1].strip()
        console.hud_alert(
            'Gathering weather data for {}, {}'.format(city_st[0].title(),
                                                       st.upper()), 'success',
            1)

    # Picked a city from list
    if city_picked:
        the_city, st, zcode = cities[row[1]]
        if zcode:
            console.hud_alert(
                'Gathering weather data for {}, {}'.format(the_city, st),
                'success', .50)

    if len(err) == 0:
        # If 'X' on form tapped
        if not btn_weather and not btn_type and not city_picked:
            err = 'Script Cancelled.'
            exit(err)

    return lat, lon, city_typed_in, st, zcode
Ejemplo n.º 51
0
            try:
                result = str(math.log(num(labelmain.text),
                                      num(labelbase.text)))
                labelmain.text = result
            except ValueError:
                try:
                    result = str(math.log(num(labelmain.text), 10))
                    labelmain.text = result
                except Exception as error:
                    labelmain.text = str(error)
                    print(error)
            shows_result = True
        elif t != '=':
            shows_result = False


def copy_action(sender):
    '@type sender: ui.Button'

    clipboard.set(sender.superview['labelmain'].text)
    hud_alert('Copied')


v = ui.load_view('Log Calculator')
if ui.get_screen_size()[1] >= 768:
    # iPad
    v.present('sheet')
else:
    # iPhone
    v.present(orientations=['portrait'])
Ejemplo n.º 52
0
            elif line == 3:
                text3 += sender.name.upper()
            elif line == 4:
                text4 += sender.name.upper()
        else:
            if line == 1:
                text1 += sender.name
            elif line == 2:
                text2 += sender.name
            elif line == 3:
                text3 += sender.name
            elif line == 4:
                text4 += sender.name


v = ui.load_view('Keyboard (UI)')
v.present(orientations=['portrait'])

while True:
    textlabel1 = v['text1']
    textlabel2 = v['text2']
    textlabel3 = v['text3']
    textlabel4 = v['text4']
    if line == 1:
        textlabel1.text = text1 + '|'
        textlabel2.text = text2
        textlabel3.text = text3
        textlabel4.text = text4
    elif line == 2:
        textlabel2.text = text2 + '|'
        textlabel1.text = text1
Ejemplo n.º 53
0
	sender.superview[BUTTON_RIGHT_NAME].enabled = False
	sender.superview[BUTTON_ERROR_NAME].enabled = False
	word = sender.superview.recite.pickone()
	if word is None:
		sender.superview.close()
	else:
		label_word.text = word.word
		textview_meaning.text = ''
		sender.superview[LABEL_RECITED_CNT_NAME].text = str(sender.superview.recite.current_index+1)
		sender.superview[LABEL_ERR_CNT_NAME].text = str(sender.superview.recite.error_cnt())
		if sender.superview.auto_speech:
			speech.say(word.word, 'en-US')


if __name__ == '__main__':
	menu = ui.load_view('Menu')
	menu.present(orientations=['portrait'], hide_title_bar=True)
	menu.wait_modal()
	if menu.start2recite:
		v = ui.load_view('Test')
		err_times_threshold = 0
		max_reciting = 100
		try:
			err_times_threshold = int(menu[TEXTFIELD_ERR_TIMES_THRESHOLD].text)
			max_reciting = int(menu[TEXTFIELD_MAX_RECITING].text)
		except ValueError as err:
			print('Can not convert to int' + str(err))
		v.filter(menu[SEGMENTEDCONTROL_ORDER].selected_index, max_reciting, err_times_threshold)
		if menu[SWITCH_SHUFFLE].value == True:
			v.shuffle()
		v.auto_speech = menu[SWITCH_SPEECH].value
Ejemplo n.º 54
0
# Created for: ICS3U
# This program displays the school name and their mascot

import ui


def mother_teresa_touch_up_inside(sender):
    # displays the school and mascot for MT
    view['school_name_label'].text = 'Mother Teresa HS'
    view['mascot_label'].text = 'Titans'


def st_joe_touch_up_inside(sender):
    # displays the school and mascot for St. Joe
    view['school_name_label'].text = 'St. Joe HS'
    view['mascot_label'].text = 'Jaguars'


def st_mark_touch_up_inside(sender):
    # displays the school and mascot for St. Mark
    view['school_name_label'].text = 'St. Mark HS'
    view['mascot_label'].text = 'Lions'


view = ui.load_view()
view.present('full_screen')
import ui

view = ui.load_view()
view.present('sheet')
Ejemplo n.º 55
0
        self_objc.addSubview_(sceneview)
        cvc.didMoveToParentViewController_(self_objc)

    def will_close(self):
        print('----close----')
        os._exit(0)


my_view = MyView(background_color=(0, .3, 0, 1))
my_view.present(
    'full_screen',
    hide_title_bar=0,
)
my_view.initialize()

seek_bar_view = ui.load_view('seek_bar')
my_view.add_subview(seek_bar_view)
seek_bar = seek_bar_view['seek_bar']
current_time = seek_bar_view['current_time']
button = seek_bar_view['button']

play_flg = True
max_time = 10
s_time = renderer.s_time


def seek_action(*_):
    global s_time, play_flg
    play_flg = False
    button.image = ui.Image.named('iob:play_256')
    if seek_bar.value is not None:
Ejemplo n.º 56
0
        if password:
            options_view['password'].text = password
    options_view.present('sheet')

def cancel_options(sender):
    options_view.close()

def save_options(sender):
    options = {}
    options['username'] = options_view['username'].text
    options['search_base'] = options_view['search_base'].text
    options['server'] = options_view['server'].text
    with open(options_path, 'w') as options_file:
        json.dump(options, options_file)
    keychain.set_password(keychain_service,
                          options['username'],
                          options_view['password'].text)
    options_view.close()

def load_options():
    if os.path.exists(options_path):
        with open(options_path) as options_file:
            options = json.load(options_file)
    else:
        options = {}
    return options

options_view = ui.load_view('options.pyui')
v = ui.load_view()
v.present('sheet')
Ejemplo n.º 57
0
computer_wins = 0
rounds = 0

def perform_guessing(number):
		player_guess = int(v['player_guess'].text)
		computer_guess = random.randint(MINIMUM, MAXIMUM)
		v['comp_guess'].text = str(computer_guess)
		v['the_number'].text = str(number)
		player_score = abs(player_guess - number)
		computer_score = abs(computer_guess - number)
		return player_score < computer_score
		
def guess(sender):
		v['label3'].text = 'The number was'
		global rounds, player_wins, computer_wins
		rounds += 1
		if perform_guessing(random.randint(MINIMUM, MAXIMUM)):
					player_wins += 1
					v['outcome'].text = 'Player Wins!'
					v['outcome'].text_color = 0.00, 0.50, 0.00
		else:
					computer_wins += 1
					v['outcome'].text = 'Computer Wins!'
					v['outcome'].text_color = 1.00, 0.00, 0.00
		v['comp_wins'].text = str(computer_wins)
		v['player_wins'].text = str(player_wins)

v = ui.load_view('guessing')
v['textview1'].text = str('Welcome to the guessing game! A number will be randomly chosen from %i to %i. The player will make a guess, and then the computer will guess. Whoever is closest wins that round!') % (MINIMUM, MAXIMUM)		
v.present('sheet')			
Ejemplo n.º 58
0
# coding: utf-8
import ui

#M
# Create the data/model
data = ['a', 45, True, 3.17]

# This data should be defined elsewhere and not here in the controller code. Perhaps it can be stored in JSON format.
# If this data were in a dictionary, it would more object-like and this is why models are usually classes.
# Even so, the model isn't the data, but perhaps a class that gets or manipulates the data. A model is more of an object, thus the name 'model' makes more sense now.

#V
# Get the views/user interface
root_view = ui.load_view('root_view')
view1 = root_view['view1']
view2 = root_view['view2']
tableview = view2['tableview1']

#C
# Connect the model to the view
tableview.data_source = ui.ListDataSource(data)

# The above code should be the only code in this controller as it is the logic that connects the model to the view(s).

# Now let's present it
root_view.present()

# Now the idea of a splitView controller makes sense. It just contols two views instead of one and handles how data gets exchanged between them. You would have two root views, one that is a masterview, and another that is a detail view.

# However, the master and detail are not exactly views only, but viewcontrollers thenselves. In the case of pythonista, they would be python files with attatched views. So, these scripts could be impoorted into the splitViewController script.
Ejemplo n.º 59
0
modes = {
    'Lydian': [0, 2, 4, 6, 7, 9, 11],
    'Ionian': [0, 2, 4, 5, 7, 9, 11],
    'Mixolydian': [0, 2, 4, 5, 7, 9, 10],
    'Dorian': [0, 2, 3, 5, 7, 9, 10],
    'Aeolian': [0, 2, 3, 5, 7, 8, 10],
    'Phrygian': [0, 1, 3, 5, 7, 8, 10],
    # 'Locrian':[0, 1, 3, 5, 6, 8, 10]
}

datab = sqlite3.connect('Data.sqlite')
data = datab.execute(SELECT).fetchone()

ratio = value = [0, 0]
correct = None
timer = 0

view = ui.load_view('Scale Degrees.pyui')
nav = ui.NavigationView(view)

options = view['options']
main = view['main']
results = view['results']['results1']
timer_label = options['timer']['timer1']
timer_slider = options['timer']['timer2']
question_label = options['question']['question1']
question_slider = options['question']['question2']
attempts = options['attempts']['attempts2']

setup()
Ejemplo n.º 60
0
    paragraphs = []
    for i in xrange(value2):
        p = fake.paragraph(nb_sentences=value1, variable_nb_sentences=True)
        paragraphs.append(p)
    text = '\n\n'.join(paragraphs)
    textview.text = text


def copy_action(sender):
    clipboard.set(sender.superview['textview1'].text)
    console.hud_alert('Copied')


def insert_action(sender):
    text = sender.superview['textview1'].text
    start, end = editor.get_selection()
    editor.replace_text(start, end, text)
    if not platform.machine().startswith('iPad'):
        view.close()


def randomize_action(sender):
    global seed
    seed = random.randint(0, 9999)
    slider_changed(sender)


view = ui.load_view('lorem')
view.present('popover')
slider_changed(view['slider1'])