omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Help! I need help thinking of python projects I can do.

    Pythonista
    7
    35
    10857
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mikael
      mikael @robStacks last edited by

      @robStacks, suggest moving the Vector implementation to a file called vector.py in site-packages. Then you can import it and it does not distract you from your own code.

      robStacks 1 Reply Last reply Reply Quote 1
      • robStacks
        robStacks @mikael last edited by

        @mikael Yes thx for pointing that out to me did so and is so much better👍🏻

        1 Reply Last reply Reply Quote 0
        • Bumbo Cactoni
          Bumbo Cactoni last edited by

          Yay! I’ve thought of a good project to do! Hopefully it won’t be too complicated... by the way, does anyone know how to display a picture? I’ve tried googling it, but it’s all a load of mumbo jumbo to me.

          1 Reply Last reply Reply Quote 0
          • stephen
            stephen last edited by stephen

            @Bumbo-Cactoni

            Using Image Module:

            import Image
            
            with Image.open('my_img.png') as img:
                img.show()
                
            

            Using ui Module:

            import ui
            
            class MyView(ui.View):
                def __init__(self, *args, **kwargs):
                    self.img = ui.Image.named('my_img.png')
                    self.iv = ui.ImageView(
                        image=self.img,
                        width=ui.get_screen_size()[0],
                        height=ui.get_screen_size()[1])
                    self.add_subview(self.iv)
                    
            MyView().present('fullscreen')
            

            Using scene Module:

            import scene
            
            class MyScene(scene.Scene):
                def setup(self):
                    self.sn=scene.SpriteNode(
                        texture=scene.Texture('my_img.png'),
                        parent=self,
                        position=self.size/2)
                        
            scene.run(MyScene())
            
            1 Reply Last reply Reply Quote 1
            • Bumbo Cactoni
              Bumbo Cactoni last edited by Bumbo Cactoni

              @stephen
              Thank you!

              stephen 1 Reply Last reply Reply Quote 0
              • stephen
                stephen @Bumbo Cactoni last edited by

                @Bumbo-Cactoni Your Welcome

                1 Reply Last reply Reply Quote 1
                • Bumbo Cactoni
                  Bumbo Cactoni last edited by

                  Now I have another question: How do you display a picture that you can move with your finger?

                  stephen 1 Reply Last reply Reply Quote 0
                  • stephen
                    stephen @Bumbo Cactoni last edited by

                    @Bumbo-Cactoni

                    😁 I like making these examples! Give me just a few.

                    1 Reply Last reply Reply Quote 0
                    • Bumbo Cactoni
                      Bumbo Cactoni last edited by Bumbo Cactoni

                      @stephen
                      Have you ever seen, like, those super simple block-programming apps? That they use to semi-teach people to program?

                      stephen 1 Reply Last reply Reply Quote 0
                      • Bumbo Cactoni
                        Bumbo Cactoni last edited by

                        I am trying to make my own block-programming thingy, but I don’t know how to create the blocks, make them movable, or even make them connect together.

                        1 Reply Last reply Reply Quote 0
                        • stephen
                          stephen @Bumbo Cactoni last edited by

                          @Bumbo-Cactoni

                          Like minecraft/terreria?

                          1 Reply Last reply Reply Quote 0
                          • Bumbo Cactoni
                            Bumbo Cactoni last edited by Bumbo Cactoni

                            @stephen

                            You mean like moving the items in the inventories?
                            If so, yes, that is kinda what I mean.

                            stephen 1 Reply Last reply Reply Quote 0
                            • stephen
                              stephen @Bumbo Cactoni last edited by

                              @Bumbo-Cactoni

                              
                              from scene import *
                              
                              def Dirt(parent, pos, size=(64, 64)):
                                  sn=SpriteNode(
                                      texture=Texture('plf:Ground_GrassCenter'),
                                      parent=parent,
                                      anchor_point=(0.0, 0.0),
                                      size=size,
                                      position=pos)
                                  return sn
                              
                              def Stone(parent, pos, size=(64, 64)):
                                  sn=SpriteNode(
                                      texture=Texture('plf:Ground_DirtCenter'),
                                      parent=parent,
                                      anchor_point=(0.0, 0.0),
                                      size=size,
                                      position=pos)
                                  return sn
                              
                              def fixed_position(x, fixed_val=64):
                                  return x - x%fixed_val
                                      
                              class MyScene(Scene):
                                  def setup(self):
                                      self.active_block=None
                                      self.anchor_point=(0.0, 0.0),
                                      self.dirt_button=Dirt(self, (self.size[0]/2-80, self.size[1]-196))
                                      self.stone_button=Stone(self, (self.size[0]/2+80, self.size[1]-196))
                                      
                                  
                                  
                                  def touch_began(self, touch):
                                      if touch.location in self.dirt_button.frame:
                                          self.active_block=Dirt(self, touch.location)
                                      if touch.location in self.stone_button.frame:
                                          self.active_block=Stone(self, touch.location)
                                  
                                  def touch_moved(self, touch):
                                      if self.active_block:
                                          self.active_block.position=touch.location
                                      
                                      
                                  def touch_ended(self, touch):
                                      x, y = self.active_block.position
                                      self.active_block.position=(fixed_position(x), fixed_position(y))
                                      self.active_block=None
                                
                              run(MyScene())
                              
                              
                              1 Reply Last reply Reply Quote 1
                              • Bumbo Cactoni
                                Bumbo Cactoni last edited by

                                Thank you! I would not have been able to figure that out on my own.

                                stephen 1 Reply Last reply Reply Quote 0
                                • Bumbo Cactoni
                                  Bumbo Cactoni last edited by Bumbo Cactoni

                                  @stephen
                                  Also, is there any way to set my own sprite/look for the objects? Like, make the dirt one look however I want it to?

                                  1 Reply Last reply Reply Quote 0
                                  • ccc
                                    ccc last edited by

                                    texture=Texture('plf:Ground_DirtCenter') is what sets the look. Other textures (images) are available to you as discussed in the Pythonista docs You can access built-in images in Pythonista using the [+] button at the top of the editor.

                                    1 Reply Last reply Reply Quote 0
                                    • stephen
                                      stephen @Bumbo Cactoni last edited by

                                      @Bumbo-Cactoni said:

                                      Thank you! I would not have been able to figure that out on my own.

                                      no problem 😎 and im sure you would of got the hang of it. its only intimidating at first then once you get a couple projects done it goes smoothly.

                                      @Bumbo-Cactoni said:

                                      @stephen
                                      Also, is there any way to set my own sprite/look for the objects? Like, make the dirt one look however I want it to?

                                      just create a png jpg or tiff image, then import it and inside Texture() pass the string path or ui.Image for the one you made. keep in mind the balance of filesize to quality. and resizing if your going to use multiple coppies you want to change scale instead of size.

                                      freindly tip:

                                      Use a dict to cache your Texture for performance.

                                      
                                      class MyScene(Scene):
                                          def setup(self):
                                              self.cache={"dirt":Texture('path/img1.png', "stone":Texture('path/img2.png'}
                                          
                                          def Dirt(self):
                                              node=SpriteNode(
                                                  texture=self.cache['dirt'],
                                                  parent=parent,
                                                  anchor_point=(0.0, 0.0),
                                                  size=size,
                                                  position=pos)
                                              return node
                                      

                                      instead of creating a new Texture each time

                                      1 Reply Last reply Reply Quote 0
                                      • Drizzel
                                        Drizzel last edited by Drizzel

                                        @Bumbo-Cactoni I'm a bit late to the party, but you could always check out Cambidge IGCSE Computer Science past papers. Just search for them in your favourite search engine. They provide beginner level excercises and solutions, since the exams are aimed at students with 2 years of coding experience.
                                        Just be aware that for every year, there's one paper with a coding excercise (the one you want) and one paper with theory (boring).

                                        I had to pass this exam in 2018, just as an example
                                        There's more here.

                                        1 Reply Last reply Reply Quote 1
                                        • Bumbo Cactoni
                                          Bumbo Cactoni last edited by

                                          Thank you

                                          1 Reply Last reply Reply Quote 0
                                          • donnybahama
                                            donnybahama last edited by donnybahama

                                            @Bumbo-Cactoni
                                            Can you think of something useful that you would use often? Even if it’s an app that you already have, you could write a clone from scratch. My first Python app will be an app that helps me with my small business (tracking and logging actions taken and status of individual jobs). It will automate/streamline a lot of the day-to-day stuff I do repetitively, help me stay organized, and prevent things from “slipping through the cracks”. I’m in the beginning phase, outlining the workflow and functionality. Once that’s done, I’ll do some screen mockups. Then...Pythonista time!

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums | Contributors