• DavinE

    @cvp said:

    @DavinE please, try as method of an ui.View

      def get_screen_size(self):              
          app = UIApplication.sharedApplication().keyWindow() 
          for window in UIApplication.sharedApplication().windows():
              ws = window.bounds().size.width
              hs = window.bounds().size.height
              break
          return ws,hs
    

    @cvp my friend, this works wonderfully

    Thanks a lot :D

    posted in Pythonista read more
  • DavinE

    Hi guys,

    I need some help for my code example....
    I am using ui.get_screen_size() to get my width and height.... but when i use the iPad in split screen the width and height is not correct... in my case both 1366 (width)

    Is there a way to solve this here ?

    posted in Pythonista read more
  • DavinE

    @cvp said:

    @ihf I'm back from vacation but I brought the Covid with me 😢, thus I'll need some time before I'm really back on the ScrollView version.

    Get well soon @cvp

    posted in Pythonista read more
  • DavinE

    @JonB said:

    Are you pulling the data from MySQL from your datasource ? Why not set up your query so you get a sorted list.

    Or, are you passing in a list? In that case, just use sort or sorted instead before assigning to your datasource items.

    If the issue is that you have
    1
    10
    2

    And you want these sorted as numbers, rather than as alphabetical strings, then you need to sort on a key that converts to int first.

    i missed: ORDER BY barcode ASC lol....

    this works now.

    posted in Pythonista read more
  • DavinE

    I have two other Questions for it.

    Pic

    1. Is it possible to sort the Numbers correctly ? Image: 30/00001 then 30/00070 ?
    2. Can i set the TableView Height to my Keyboard ?

    posted in Pythonista read more
  • DavinE

    @cvp said:

    @DavinE said

    But the whole thing is displayed in the Console

    You only have to replace 'panel' by 'fullscreen' and display will be done in normal ui.View

    oh, okay if that's all it is, I'll take a look.

    posted in Pythonista read more
  • DavinE

    @JonB said:

    @cvp you might consider a search controller, which behaves the way one expects in iOS

    https://github.com/tdamdouni/Pythonista/blob/master/_2017/SearchableTable.py

    Yes that is of course nicer...
    But the whole thing is displayed in the Console... and I can not really understand the whole thing 🙈
    So that a customization would be modest for me....
    Will test it with @cvp's example and try.

    posted in Pythonista read more
  • DavinE

    @cvp said:

    @DavinE please try this quick and dirty example

    import ui
    
    class MyView(ui.View):
      def __init__(self,w,h):
          self.width = w
          self.height = h
          
          # init existing codes
          self.codes = ['1','2','25','2587','2549','256625/10000','3','33','4','44/45']
          
          # TextField for search
          search_width = self.width - 100
          search_text = ui.TextField(name='search_text')
          search_text.text = ''
          search_text.width = search_width - 100
          search_text.height = 32
          search_text.x = (self.width - search_width)/2
          search_text.y = 10
          search_text.border_color = 'blue'
          search_text.border_width = 3
          search_text.text_color = 'blue'
          search_text.keyboard_type = ui.KEYBOARD_DEFAULT
          search_text.autocorrection_type = False
          search_text.alignment = ui.ALIGN_LEFT
          search_text.clear_button_mode = 'while_editing'
          search_text.font= ('Helvetica',20)
          search_text.delegate = self
          self.add_subview(search_text)
          
          # ListDataSource for search TableView
          found_codes = ui.TableView(name='found_codes')
          found_codes.allows_multiple_selection = False
          found_codes.text_color = 'black'
          found_codes.font= ('Courier',12)
          found_codes.row_height = 50
          found_codes.x = search_text.x
          found_codes.y = search_text.y + search_text.height + 10
          found_codes.width = search_width
          found_codes.height = self.height - 130
          found_codes.border_color = 'blue'
          found_codes.border_width = 3
          found_codes.data_source = ui.ListDataSource(items=[])
          self.add_subview(found_codes)
          
      def textfield_did_change(self, field):
          txt = field.text
          lst = []
          for code in self.codes:
              if txt and code.startswith(txt):
                  lst.append(code)
          self['found_codes'].data_source.items = lst
    
    def main():
      w, h = ui.get_screen_size()
      my_back = MyView(w,h)
      my_back.background_color='white'
      my_back.name = 'for @DavinE'
      my_back.present('fullscreen',hide_title_bar=False)
    
    # Protect against import  
    if __name__ == '__main__':
      main()
    

    Yes, that's exactly what I meant.
    With it I can try the days once around 👍

    posted in Pythonista read more
  • DavinE

    @cvp
    I think from the consideration it is exactly what I'm looking for and meant 😊

    Will try to implement in the near future once when I have questions I'll get back to you here (but may take a while at the moment a lot of stress)

    posted in Pythonista read more
  • DavinE

    Hey, ..

    I have a question in connection with the picture:
    https://imgur.com/Q5vFkpG

    Is it possible to create a list as Dropdown... to show my QR-Codes with the beginning Numbers and in the best way to select them too ?
    like the example in the Picture:
    --> 25
    --> 2587
    --> 2549
    --> 2566
    --> ...
    --> ..
    --> .
    --> 25/00001
    --> 25/00008
    --> 25/00017
    --> 25/000198
    --> ...
    --> ..
    --> .
    only the numbers which are available.. (all QR-Codes stored in a MySQL database)

    I hope you can understand my question and have suggestions :D

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!