omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. fergal

    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.


    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 5
    • Best 0
    • Controversial 0
    • Groups 0

    fergal

    @fergal

    0
    Reputation
    595
    Profile views
    5
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    fergal Unfollow Follow

    Latest posts made by fergal

    • RE: Boggle App, need help changing labels 3x in a function

      @JonB
      No problem on the hijacking! I think it's great that you ran with it, I picked it because it is an achievable project for me, but also because it seems like a fun programming challenge. It was my first CLI challenge I set myself last year!

      There are a million one player versions out there, my family really enjoys board games, so I want to be able to pull out my phone or ipad at the restaurant while waiting for food and play boggle with my daughters, we'll use pen and napkins for words. Keeping a score tally might be a fun activity to add in afterwards.

      Your idea for the dice is great, I was going to try rounded corners with a circle in the middle as my final goal, so this is great.

      Your code looks BRILLIANT, I can't wait to dig into it. Thank you for breaking it up for me to digest. I usually feel that one good example that I can understand will feed me for weeks!

      Again, I appreciate it!

      posted in Pythonista
      fergal
      fergal
    • RE: Boggle App, need help changing labels 3x in a function

      @JonB
      Ok JonB, I've been working on understanding what is going on and how I can implement this awesome work you've showed me.

      For me, the important part is that I understand each piece so I know how it works, so I do that by building the script up slowly and checking that I understand each piece as I do it.

      I started with creating the 'dice' here. You used buttons and were designing for an iphone screen size. I'm starting with an iPad size and moving to iPhone afterwards. So my first question is, can I work on the animations if the 'dice' are labels rather than buttons?

      The only reason that I am looking for labels over animation is that I want to be able to change the text size and weight and I'm not sure how to do that with buttons. BUT I can't change the corner radius with labels, so I'm kinda stuck.
      Here is what I have so far,
      https://gist.github.com/rgregory1/b96079da685fe3b5bca5407930155d7f

      My game plan is:

      • achieve the look I'm after
      • make them roll correctly
      • begin to understand the animation

      So knowing that, do I need to make the 'dice' buttons rather than labels?

      Thanks for any help!

      posted in Pythonista
      fergal
      fergal
    • RE: Boggle App, need help changing labels 3x in a function

      HOLY COW, ok, that's going to be a lot more to digest! Thanks again, can't wait to dive in.

      posted in Pythonista
      fergal
      fergal
    • RE: Boggle App, need help changing labels 3x in a function

      Wow JonB! I'm blown away by the detailed and awesome response!

      I'm at work now but I will try to dissect and understand this the best I can tonight when I get home! As you can tell by my code, I'm just beginning my python journey and my Pythonista journey as well. This should help a great deal.

      posted in Pythonista
      fergal
      fergal
    • Boggle App, need help changing labels 3x in a function

      I've got a working boggle app as my first pythonista project, I like it and it's functional, but I want to add some pizzaz to it and that's where I'm having trouble.

      You can see the whole (very simple) project at https://github.com/rgregory1/boggle_pythonista

      I have a function called button_press that rolls the dice and adds text to the 'dice' labels. I want to change the function to show a random assortment of dice once a second for 3 times, then leave the last one there for the game. I can make it happen, but it won't show the dice until the function finishes, so in effect is that it blanks for 3 seconds then continues.

      I managed to run a timer at the same time as my other functions with the @ui.in_background decorator, but that won't work for this one for some reason.

      Here is my code (shortened for 4 dice rather than 16 for brevity)

      def button_press(self):
      	print('button was pressed')
      	self.title = "Play Game"
      	dice_rolls = roll_all_dice(dice)
      	label1.text = str(dice_rolls[0])
      	label2.text = str(dice_rolls[1])
      	label3.text = str(dice_rolls[2])
      	label4.text = str(dice_rolls[3])
      	with open('dice_rolls.json', 'w') as f:
      		json.dump(dice_rolls, f)
      	countdown()
      	main_button.action = show_letters
      

      The effect I want would be this:

      def button_press(self):
      	print('button was pressed')
      	self.title = "Play Game"
      	dice_rolls = roll_all_dice(dice)
      	label1.text = str(dice_rolls[0])
      	label2.text = str(dice_rolls[1])
      	label3.text = str(dice_rolls[2])
      	label4.text = str(dice_rolls[3])
          time.sleep(1)
          dice_rolls = roll_all_dice(dice)
      	label1.text = str(dice_rolls[0])
      	label2.text = str(dice_rolls[1])
      	label3.text = str(dice_rolls[2])
      	label4.text = str(dice_rolls[3])
          time.sleep(1)
          dice_rolls = roll_all_dice(dice)
      	label1.text = str(dice_rolls[0])
      	label2.text = str(dice_rolls[1])
      	label3.text = str(dice_rolls[2])
      	label4.text = str(dice_rolls[3])
      	with open('dice_rolls.json', 'w') as f:
      		json.dump(dice_rolls, f)
      	countdown()
      	main_button.action = show_letters
      

      I tried moving this chunk to a function to make it look better,

      dice_rolls = roll_all_dice(dice)
      	label1.text = str(dice_rolls[0])
      	label2.text = str(dice_rolls[1])
      	label3.text = str(dice_rolls[2])
      	label4.text = str(dice_rolls[3])
      

      but I thought I'd leave it in a block to try and problem solve it?

      Thanks for any help!

      posted in Pythonista
      fergal
      fergal