Difference between revisions of "Tkinter"

Jump to navigation Jump to search
919 bytes added ,  06:34, 17 April 2020
no edit summary
Line 12: Line 12:




  <nowiki>''' tk_calculator_tiny2.py</nowiki>
  <nowiki>''' cal.py</nowiki>
  A updated tiny calculator using the Tkinter GUI toolkit
  A updated tiny calculator using the Tkinter GUI toolkit
  you can type in functions contained in module math
  you can type in functions contained in module math
Line 25: Line 25:
         # the root will be self
         # the root will be self
         tk.Tk.__init__(self)
         tk.Tk.__init__(self)
         self.title("Tiny TK Calculator")
         self.title("Darknet TK Calculator")
         # use width x height + x_offset + y_offset (no spaces!)
         # use width x height + x_offset + y_offset (no spaces!)
         #self.geometry("300x150+150+50")
         #self.geometry("300x150+150+50")
Line 103: Line 103:
  python3 cal.py  
  python3 cal.py  


=== Explanation of the source code ===
The below link is the origin of the [[source code]].




Line 109: Line 112:


https://www.daniweb.com/programming/software-development/code/467452/updated-tiny-tkinter-calculator-python
https://www.daniweb.com/programming/software-development/code/467452/updated-tiny-tkinter-calculator-python
The lines confined by three ' are [[comment]]s. See [[Python]] article to see more detailed explanation.
The below [[code]]s are for [[Python]] 2 so I removed or modified them. Because most people use Python 3 instead of Python 2 in these days.
# avoid integer division by Python2
from __future__ import division
and
try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk




Line 121: Line 142:




from math import *
from functools import partial
import tkinter as tk
The second line means that importing "partial" from "functools". The first line means that importing everything from "math". The last line means that importing "tkinter" as the name "tk".
Under MyApp [[class]], there are three [[function]]s defined by "def". [[Definition]] is different to [[declaration]].


==Description==
==Description==
Line 211: Line 242:
* [[Beautiful Soup]]
* [[Beautiful Soup]]
* [[Pygame]]
* [[Pygame]]
* [[Security]]
* [[Program]] ([[Programming]])
* [[Program]] ([[Programming]])
*[[Computer program]], a collection of instructions that performs a specific task when executed by a computer
* [[Computer program]], a collection of instructions that performs a specific task when executed by a computer
*[[Computer programming]], the act of instructing computers to perform tasks
* [[Computer programming]], the act of instructing computers to perform tasks
**[[Programming language]], an artificial language designed to communicate instructions to a machine
** [[Programming language]], an artificial language designed to communicate instructions to a machine
*[[Programmer]], a person who writes software
* [[Programmer]], a person who writes software


== References ==
== References ==
20

edits

Navigation menu