• vcr80

    Hy!

    Pythonista just deleted what I coded in over an hour.

    Here's what I did:

    1. Coded and tested my script multiple times but never left the script file
    2. suddenly the console became unresponsive (couldn't touch X to stop the script)
    3. Force Quit Pythonista
    4. Reopen Pythonista
    5. all work gone

    That sure is an unexpected behaviour - is it a bug?

    Thanks

    posted in Pythonista read more
  • vcr80

    Ah, thanks @omz - got it now!

    posted in Pythonista read more
  • vcr80

    Unfortunately, this gives me an Error. "Inconsistent number of rows after deletion.", @JonB

    posted in Pythonista read more
  • vcr80

    The SQL-Table row id.

    Thanks! I'll have a look at it!

    I solved it (way!!) less elegant but simpler: I just wrote the SQL row ID into the row text. That'll do for now. I was hoping for a simpler solution.

    posted in Pythonista read more
  • vcr80

    Hy!

    I'm reading data from a sqlite3 database and when I delete the TableViewCell I want to delete the corresponding row in the sqlite3 database. Therefor I must know the id of the row in question. I already asked how to recreate the original visual behavior of deleting a TableViewCell over here: https://forum.omz-software.com/topic/2733/delete-rows-in-tableview - And in the same function I would like to get the row id of that entry in the cell and delete the row in the sqlite database.

    Thanks!

    posted in Pythonista read more
  • vcr80

    What would tableview_delete() look like if I want to show the default visual behaviour and perform some additional action?

    posted in Pythonista read more
  • vcr80

    Is there a tutorial on how to create custom TableViewCells (with multiple subviews like labels, images, etc.) and then populate them with data?

    Ah - https://forum.omz-software.com/topic/1922/adding-a-label-to-tableviewcell-it-s-offset-by-one - seems to be a good starting point!

    posted in Pythonista read more
  • vcr80

    Thanks, @ccc - That works fine! Could you explain the part with NavView(object)? Why did you change it and what does it change in the background? The rest of your changes are clear to me.

    Sorry, @Phuket2 I didn't mean it in any offensive way. I am really searching for an introduction to UI Designer of Pythonista because I really want to know how things work. I too think that understanding how views work will help a lot! So again: did I miss something or are you simple supposed to find out on your own or should one already know how those things work because one should know how Python works?

    posted in Pythonista read more
  • vcr80

    Great, @ccc - that cleared things up!
    I was able to set the text of a label inside another subview of the navigation view now.

    However, I still don't see how I could access the navigation view itself when a button inside the the subview is pressed. NavView.push_view(root) and NavView.v.push_view(root) didn't work. Knowing how to access the navigation view from within a subview could come in handy if I'd like to close the current subview as soon as a button is pressed or if i want to load yet another subview when the button is pressed.

    Updated Gist: https://gist.github.com/nitricware/468b31a1b5363c4474e1
    Lines 10 and 42 show my new issues...

    @Phuket2 I'd like to! Did I miss some kind of introduction to Pythonista UI creation? Or are you supposed to know how those kind of things work (Installed Pythonista less than a week ago.)?

    posted in Pythonista read more
  • vcr80

    sure, @ccc here it is: https://gist.github.com/nitricware/f82416c411586404e5d2

    unfortunately the iteration you posted, @Phuket2 just lists the subviews of the view where the pressed button is located... but not the subviews of the parent navigation view nor the subviews of the root view, that itself is loaded into the navigation view...

    posted in Pythonista read more
  • vcr80

    How can I access a subview (i.e. a label), that is in another subview of a NavigationView?

    Expample: I have a Navigation View. Inside live two Subviews. Subview 1 has a label in it, subview 2 has a button. How can I change the label of the text, when the button is pressed? (Navigation View and the two SubViews are three different files. I have described my setup in another thread.)

    posted in Pythonista read more
  • vcr80

    How can I push the scanner as a subview to a navigation view, get the first result it scanned, close the scanner an process the number, the scanner returned?

    I already managed to load the scanner as a sub view of a navigation view but now I'm stuck.

    posted in Pythonista read more
  • vcr80

    @dgelessus you're right. sorry! Next time, I'll copy the code!

    I changed my code based on your answer: I created a third pyui file for the root view and pushed the root view via code to the navigation view rather than in the UI Builder and I set the button_right_items in the code that loads the root view.

    That worked!

    Here's exactly what I did in case someone is stuck with the same very basic problem:

    I created a script file with a UI file. They share the same filename (say NavView.py and NavView.pyui). In The pyui file, all I did was set the Custom Class View to ui.NavView. In its corresponding py-file, i created class NavView(ui.View). Also, I created two stand alone UI files for designing the root view and the sub view.

    This is the class:

    # coding: utf-8
    
    import ui
    
    class NavView(ui.View):
        def __init__(self):
            # Load the default view that's placed inside the Navigation View.
            # This root view has its own pyui file (here: RootView.pyui).
            # That makes it easier to design the root view.
            root = ui.load_view('RootView.pyui')
            # Set the titlebar text of the Navigation View when the root view is loaded
            root.name = 'Root View'
            # Specify the visible buttons in the navigation view titlebar when the root view is visible.
            root.right_button_items = [ui.ButtonItem(action=self.openSubView, image=ui.Image.named('ionicons-close-24'))]
            # Create the Navigation View with the root view preloaded
            self.v = ui.NavigationView(root)
            self.v.present('sheet')
            
        def openSubView(self,sender):
            # Load the sub view thats loaded when the defined button in the Navigation View is pressed while the root view is loaded
            sub = ui.load_view('SubView.pyui')
            # This text will be displayed as the Navigation View's titlebar text
            sub.name = 'Sub View'
            # Display the sub view instead of the root view
            self.v.push_view(sub)
            
    # Call the class        
    NavView()
    

    If you have any suggestion on how to improve the code, I'd love to hear it!


    The above code works great as long as I don't actually want to do anything with the code. I'm not getting it. Did I miss any kind of tutorial or documentation?

    Say I have a button in one of the sub views. How do I make the button (with action set to buttonFunction) do anything? def buttonFunction(sender) below the class doesn't work. def buttonFunction(self, sender) inside the class doesn't work either. And it doesn't matter wether every view (not just the Navigation View Container pyui) or just the top level pyui that has the Navigation View in it has its custom view class set to ui.NavView or not.

    I'm really confused since I can't find anything like a introduction to Pythonista UI Designer...

    posted in Pythonista read more
  • vcr80

    I created three files:
    A pyui file and a corresponding py file (MyView.pyui and MyView.py) plus a subview pyui file (MySubView.pyui)

    I then was able to create a button in the main view (where the navigation view is located) which, when pressed, pushes the subview into to navigation view. However doing it that way, makes this button stay, no matter which root/subview is visible inside the navigation view.

    How can I create a right_button_item inside MyView.py= I tried

    v = ui.load_view
    v['navigationview1'].right_button_items = ui.ButtonItem[...]
    

    But that does nothing at all

    v = ui.load_view
    v.right_button_items = ui.ButtonItem[...]
    

    Adds it to the top level view.

    What do I miss?

    posted in Pythonista read more
  • vcr80

    Actually that's not what I'm looking for, @deloriel42 - @ccc that sounds like what I'm looking for!

    I'm just looking for a view, that displays a plain monthly calendar overview. When the user taps a date, a subview will open, letting him create new (app-specific) appointments and view existing ones.

    posted in Pythonista read more
  • vcr80

    not really, because I'd like an overview that shows the whole month like Calendar.app (maybe including highlighting dots if there is something scheduled for that day)

    posted in Pythonista read more
  • vcr80

    Hy!

    I'm looking for a possibility to implement a calendar view (like in any application that uses a calendar). Is there an easy way? Do I have to create one using loops and labels/buttons?

    I'm using Pythonista 2.0.

    Thanks

    • vcr80

    posted in Pythonista read more
  • vcr80

    So just to get it right: any action listener, must be defined before ui.load_view but things that change elements of the view must be placed beneath it?

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!