In this workshop you will:
- Develop a simple UI in Python
In the lecture this week we looked at user interface implementation. For this weeks workshop, we will develop a simple interface for a guessing game.
Task 1 – Setup wxPython
- Use Annaconda or pycharm to install the wxpython library
> conda install wxpython
Or do it using the Anaconda Navigator or PyCharm Package manager.
- You will need to do this each time you restart the lab
- Open up your IDE, and attempt to: import wx and run it.
Task 2 – Guessing game
- Develop a simple GUI for a guessing
- The game should begin when the program is run by generating a random number between 1 and 100. It should provide a text field for the user to enter a guess, a button to submit their guess, and display “higher” or “lower” somewhere on the interface after each guess, as well as the number of guesses they have
- When the user correctly guesses the number, the program should display a message box congratulating them, and then terminate with self.Close(True)
Here is the marking guideline:
- Create frame and panel. (1 mark)
- Properly handle keyboard input (1 mark)
- Properly implement the guess function (2 marks for 2810ICT students, 1 mark for 7810ICT students):
- Pick a number as the guessing target. If the input number is smaller or larger than the target number, give prompt. If the target number is reached, congratulate the user. (1 mark)
- Output the number of guesses in the interface (1 mark for 7810ICT students)
本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝交易！
E-mail: [email protected] 微信:dmxyzl003