Showing posts with label message box. messagebox. Show all posts
Showing posts with label message box. messagebox. Show all posts

Monday, 11 May 2015

Cross-multiplication Calculator (The Rule Of Three)

In this post I will put a code tha makes a 'calculator' that uses cross-multiplication (or like the title says, The Rule Of Three).

Well, (Wikipedia link-here) one can cross-multiply to determine the value of a variable.

In this case it's like:

a * x = b * c
Which ends up (for the 'x' variable) in:

 x = c * b / a

Thursday, 7 May 2015

Using tkMessageBox

Now I'm going to use the module "tkMessageBox", which is used to display message boxes, first in a simple code in order to show how it goes, then using it with a previous posted example :P.

The simple code has been a used with one of the functions that "tkMessageBox" provides (for a little bit more of information you can go to the next link : Python Tkinter tkMessageBox;  or this other one for the code of the message box of the first image in this post)

Anyway, this is the simple code (a warning will be shown when the user clicks the button that says "Warning"):

import Tkinter as tk
import tkMessageBox

root = tk.Tk()

def info():
   tkMessageBox.showwarning("Warning", "Resources changed")

tk.Button(root, text = "Pop up", command = info).pack()

root.mainloop()