• stephen

    @cvp 😉 happends to the greatet of us

    posted in Pythonista read more
  • stephen

    @cvp just hit the ⋮ and then Edit. tthe top you should be ableto select topic an edit it

    posted in Pythonista read more
  • stephen

    awesome! good job 🙃

    posted in Pythonista read more
  • stephen

    Just a small peice of the RPG template.. if the community would like i can post updates along the way. for thosenwho dont know what im talking about. RPG Template is just a easy import providing the core mechanics andlogic for rpg development. currently provides character attribute system, experience and leveling system. texture handling is about 1/2 way there and im currently building the item and inventory system.

    doing this to try n help other that just want a fast poject to play with. if you have never constructed a rpg core structure before i can tell ou its no fast project.. lol if people would like regular updates just mention it in comments snd if there is any lol ill post. good day 🤓😉

    Thought i would share this small class to cache game Textures. has came in handy for myself and my fellow developers. Hopfully it will help others in thiers.

    Its pretty simply.. just creat a file named assetsthen once an instance is created it will walk through all files and folders within nd get any files ending with .png or .PNG it will then take the file name and split it at %. first section will be used as the name used to call on the cached texture.

    example:

    `iron-ore%mining-stone.png` ⇢ cached[file.split('%')[0]] = scene.Texture("iron-ore%mining-stone.png")
    then to use the cached texture
    `ASSETS('iron-ore')` gives cached `_scene2.Texture object`
    

    Hope this helps out anyone 🙃🤓😉

    from os import (walk, getcwd, path)
    from scene import Texture
    
    class Assets:
        def __init__(self):
            self.cached = dict({})
            self.CacheAssets()
            
        def __call__(self, name):
            return self.cached[name]
        
        def PrintCache(self):
            for k, v in self.cached.items():
                print(f'{k}\n\t{v}\n{"*"*42}')
    
        def CacheAssets(self):
            id: int = 0
            for r, d, f in walk(getcwd()+'/assets/'):
                for file in f:
                    if file.endswith(".png") or file.endswith(".PNG"):
                        id += 1
                        if '%' in file:
                            name: str = file.split('%')[0]
                            self.cached[name] = Texture(path.join(r, file))
                        else:
                            self.cached[f'{id}'] = Texture(path.join(r, file))
    ASSETS = Assets()
    ASSETS.PrintCache()
    

    posted in Pythonista read more
  • stephen

    @mattaeuss said:

    e Halcyon from VSCode be added to Pythonista..?

    not the exact theme. this is becaus VS has manymore elements available to color. but this is as closevas i could bet i hope it will surfice
    Halcyon theme

    here is where i referenced the colors..

    posted in General Discussion read more
  • stephen

    @cvp @7upser

    we might need to look into out objc_util module this might be the third ocurance that ive see that Apple changed API and renders our use incapable. i tried all i could and i get the same error stating the method doesnt exist.. but i did see that there might be a work around to use old ios12 styling only mjor featur that i saw that you lose is darkmode. you will only get the light mode ]. below is what i sawvabout this. its from @7upser 's link i believe its refering to swift code im not sure... but its the best i could find

    To get back iOS 12 appearance

    I wasn't able to tint the color of the selected segment, hopefully it will be fixed in an upcoming beta.
    Setting the background image of the selected state doesn't work without setting the background image of the normal state (which removes all the iOS 13 styling)
    But I was able to get it back to the iOS 12 appearance (or near enough, I wasn't able to return the corner radius to its smaller size).
    It's not ideal, but a bright white segmented control looks a bit out of place in our app.
    (Didn't realise UIImage(color:) was an extension method in our codebase. But the code to implement it is around the web)

    extension UISegmentedControl {
        /// Tint color doesn't have any effect on iOS 13.
        func ensureiOS12Style() {
            if #available(iOS 13, *) {
                let tintColorImage = UIImage(color: tintColor)
                // Must set the background image for normal to something (even clear) else the rest won't work
                setBackgroundImage(UIImage(color: backgroundColor ?? .clear), for: .normal, barMetrics: .default)
                setBackgroundImage(tintColorImage, for: .selected, barMetrics: .default)
                setBackgroundImage(UIImage(color: tintColor.withAlphaComponent(0.2)), for: .highlighted, barMetrics: .default)
                setBackgroundImage(tintColorImage, for: [.highlighted, .selected], barMetrics: .default)
                setTitleTextAttributes([.foregroundColor: tintColor, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 13, weight: .regular)], for: .normal)
                setDividerImage(tintColorImage, forLeftSegmentState: .normal, rightSegmentState: .normal, barMetrics: .default)
                layer.borderWidth = 1
                layer.borderColor = tintColor.cgColor
            }
        }
    }
    

    posted in Pythonista read more
  • stephen

    @7upser on my iPad Air2 tjis is the same give me few min to run som tests and ill be right back

    posted in Pythonista read more
  • stephen

    @7upser to show imag just use this

    ![tag](url)
    

    what did u put inside the custom attribute section on builder for the segment control

    posted in Pythonista read more
  • stephen

    @Drizzel
    im sure there is a much simpler way but...

    why not have a state checker give x time to look for a second tap before executing functionality for a single tap? possibly a decorator?

    posted in Pythonista read more
  • stephen

    @Drizzel said:

    I‘m trying to double tap on a TableViewCell without actually selecting it, but it should still be selectable on a single tap. How would I go about doing this?

    Let’s assume I have this code:

    import ui
    import gestures
    
    def double_tap(data):
      print('double tapped row', data.view.row)
    def tap(data):
      print('tapped', data.view.row)
    def long_press(data):
      print('long pressed', data.view.row)
    
    def tableview_cell_for_row(tableview, section, row):
      data = tableview.data_source.items[row]
      cell = ui.TableViewCell('subtitle')
      cell.text_label.text = data
      cell.row = row
      gestures.doubletap(cell, double_tap)
      #gestures.tap(cell, tap, number_of_touches_required = 1)
      #gestures.long_press(cell, long_press, minimum_press_duration = .2)
      
      return cell
      
    class Delegate():
      def tableview_did_select(self, tableview, section, row):
          print('selected row', row)
    
    tv = ui.TableView()
    tv.delegate = Delegate()
    tv.data_source = ui.ListDataSource([str(x) for x in range(5)])
    tv.data_source.delete_enabled = False
    tv.data_source.tableview_cell_for_row = tableview_cell_for_row
    tv.frame = (tv.frame[0], tv.frame[1], 400, 400)
    
    tv.present(style = 'sheet')
    

    i believe you might wand def tableview_cell_for_row(tableview, section, row): as a method of class Delegate instead of a global function.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!