<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>tkinter &amp;mdash; Paul Sutton</title>
    <link>https://personaljournal.ca/paulsutton/tag:tkinter</link>
    <description>Personal Blog</description>
    <pubDate>Tue, 05 May 2026 14:58:30 +0000</pubDate>
    <item>
      <title>Add  more functions</title>
      <link>https://personaljournal.ca/paulsutton/add-more-functions</link>
      <description>&lt;![CDATA[Add  more functions&#xA;&#xA;I have added a few more maths functions to the application and also provided a clear function.  There are still a few items to add to help improve debugging but the application is starting to take shape. &#xA;&#xA;Notes &#xA; &#xA;window = Tk()&#xA;window.title(&#39;Maths Application&#39;)&#xA;window.geometry(&#34;570x150&#34;) # w x h&#xA;window.resizable(0,0)&#xA;&#xA;The above code is being modified as I go. So I am changing the window size depending on what is being displayed.&#xA;&#xA;I have also made the Window title reflect the purpose of the application.&#xA;&#xA;That the source code now has &#39;result&#39; as a label rather than output.  This will show up future screenshots. &#xA;&#xA;addition app&#xA;&#xA;The code for the above is as follows. &#xA;&#xA;!/usr/bin/env python&#xA;import Tkinter # note use of caps&#xA;from Tkinter import &#xA;&#xA;window = Tk()&#xA;window.title(&#39;Maths Application&#39;)&#xA;window.geometry(&#34;570x150&#34;) # w x h&#xA;window.resizable(0,0)&#xA;&#xA;define button actions&#xA;def btn1():&#xA;&#x9;#convert box text in to integers&#x9;&#xA;&#x9;ent1 = int(entrytext.get())&#xA;&#x9;ent2 = int(entrytext2.get())&#xA;&#x9;&#xA;&#x9;#add the 2 integers and store in variable add&#xA;&#x9;add = (ent1 + ent2)&#xA;&#x9;print (add)&#xA;&#x9;&#xA;&#x9;#insert value of variable add in&#x9;to box outtext &#xA;&#x9;outtext1.insert(0,str(add)) # insert response&#xA;&#xA;def btn2():&#xA;&#x9;#print(&#34;subtraction&#34;)&#xA;&#x9;ent1 = int(entrytext.get())&#xA;&#x9;ent2 = int(entrytext2.get())&#xA;&#x9;&#xA;&#x9;#subtract the 2 integers and store in variable sub&#xA;&#x9;sub = (ent1 - ent2)&#xA;&#x9;&#xA;&#x9;&#xA;&#x9;#insert value of variable sub in&#x9;to box outtext &#xA;&#x9;outtext1.insert(0,str(sub)) # insert response&#x9;&#xA;&#x9;&#xA;def btn3():&#xA;&#x9;#print(&#34;multiply&#34;)&#xA;&#x9;ent1 = int(entrytext.get())&#xA;&#x9;ent2 = int(entrytext2.get())&#xA;&#x9;&#xA;&#x9;#multiply the 2 integers and store in variable mul&#xA;&#x9;mul = (ent1  ent2)&#xA;&#x9;&#x9;&#xA;&#x9;#insert value of variable mul in&#x9;to box outtext &#xA;&#x9;outtext1.insert(0,str(mul)) # insert response&#x9;&#x9;&#xA;&#xA;def btn4():&#xA;&#x9;#print(&#34;divide&#34;)&#xA;&#x9;ent1 = int(entrytext.get())&#xA;&#x9;ent2 = int(entrytext2.get())&#xA;&#x9;&#xA;&#x9;#multiply the 2 integers and store in variable div&#xA;&#x9;div = (ent1 / ent2)&#xA;&#x9;&#x9;&#xA;&#x9;#insert value of variable mul in&#x9;to box outtext &#xA;&#x9;outtext1.insert(0,str(div)) # insert response&#x9;&#xA;&#x9;&#xA;clear boxes&#xA;def clear():&#xA;&#x9;#print(&#34;clear boxes&#34;) # leave in for legacy testing&#xA;&#x9;entrytext.delete(0, END) # clear input box&#xA;&#x9;entrytext2.delete(0, END) # clear input box2&#xA;&#x9;outtext1.delete(0, END) # clear output box&#xA;&#x9;&#xA;btntog2 = Button( window, text =&#39;+&#39;, command=btn1) # add&#xA;btntog3 = Button( window, text =&#39;-&#39;, command=btn2)  # subtract&#xA;btntog4 = Button( window, text =&#39;x&#39;, command=btn3) #multiply&#xA;btntog5 = Button( window, text =&#39;/&#39;, command=btn4) #divide&#xA;btntog6 = Button( window, text =&#39;Clear&#39;, command=clear) #clear&#xA;btnexit = Button( window, text =&#39;Exit&#39;,command=exit)&#x9; #exit&#xA;&#xA;define some labels&#xA;box1 = Label(window, text=&#34;1st Value&#34;)&#xA;box2 = Label(window, text=&#34;2nd Value&#34;)&#xA;box3 = Label(window, text=&#34;Result&#34;)&#xA;&#xA;define entry box &#xA;entry1 = StringVar() # this is our entry box&#xA;entry2 = StringVar()&#xA;entrytext = Entry(window, textvariable=entry1) # this is our entry box&#xA;entrytext2 = Entry(window, textvariable=entry2) # this is our second entry box&#xA;&#xA;define out box &#xA;&#xA;entry2 = StringVar() # this is our output box&#xA;outtext1 = Entry(window, textvariable=entry2) # this is our output box&#xA;&#xA;display boxes&#xA;entrytext.grid(row = 3, column = 2,)  #display entry box&#xA;entrytext2.grid(row = 3, column = 3,)  #display entry box&#xA;outtext1.grid(row = 3, column = 4,) #display output box&#xA;&#xA;place labels&#xA;box1.grid(row = 1&#x9;, column = 2, padx = 5, pady = 5)&#xA;box2.grid(row = 1&#x9;, column = 3, padx = 5, pady = 5)&#xA;box3.grid(row = 1&#x9;, column = 4, padx = 5, pady = 5)&#xA;&#xA;buttons&#xA;btntog2.grid(row = 4, column = 2, padx = 1, pady = 1) # addition button&#xA;btntog3.grid(row = 4, column = 3, padx = 1, pady = 1) # subtraction button&#xA;btntog4.grid(row = 5, column = 2, padx = 1, pady = 1) # multiply button&#xA;btntog5.grid(row = 5, column = 3, padx = 1, pady = 1) # divide button&#xA;btntog6.grid(row = 4, column = 6, padx = 1, pady = 1) # clear button&#xA;btnexit.grid(row = 3, column = 6, padx = 1, pady = 1) # exit button&#xA;&#xA;window.mainloop()&#xA;&#xA;The code that I used for a previous application to detect if numerical values have been used is below but provided &#39;as is&#39; for now.&#xA;&#xA;def response():&#xA;&#x9;&#x9;&#xA;&#x9;msg = &#34;error : must be a text value&#34;&#xA;&#xA;&#x9;i = circletext.get()&#xA;&#x9;y = i.isdigit()&#xA;&#x9;l = len(circletext.get())&#xA;&#x9;#print l&#xA;&#x9;if y == True or l == 0:&#xA;&#x9;&#x9;circletext.insert(0,(msg))&#xA;&#x9;&#x9;&#xA;&#x9;else:&#x9;&#xA;&#x9;&#x9;x = random.choice(RESPONSES)&#xA;&#x9;&#x9;circletext2.delete(0, END) # clear prev output&#xA;&#x9;&#x9;circletext2.insert(0,str(x)) # insert response&#xA;&#xA;I will integrate a version of this in to the main code. &#xA;&#xA;#python, #tkinter, #programming, #python, #graphic, #applications, #bugs, #troubleshooting, #howto, #paignton, #library, #virtual, #codeclub&#xA;&#xA;Happy to provide help and support via decentralised social media.  I can be contacted on Mastodon here. You can get a free account on the http://qoto.org instance by following this link.&#xA;&#xA;cc-by logo&#xA;&#xA;Licenced under Attribution 4.0 International (CC BY 4.0)&#xA;&#xA;hr&#xD;&#xA;&#xD;&#xA;table&#xD;&#xA;thead&#xD;&#xA;trtda rel=&#34;me&#34; href=&#34;https://qoto.org/@zleap&#34;Mastodon/a/td&#xD;&#xA;tda href=&#34;https://wiki.ircnow.org/?n=Shelllabs.Intro&#34;ShellLabs/td&#xD;&#xA;tda href=&#34;https://joinmastodon.org/&#34;Join Mastodon/a/td/tr/thead/table&#xD;&#xA;center&#xD;&#xA;AI statement : b Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. /b&#xD;&#xA;/center&#xD;&#xA;&#xD;&#xA;a href=&#34;https://liberapay.com/PaulSutton/donate&#34;img alt=&#34;Donate using Liberapay&#34; src=&#34;https://liberapay.com/assets/widgets/donate.svg&#34;/a&#xD;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Add  more functions</p>

<p>I have added a few more maths functions to the application and also provided a clear function.  There are still a few items to add to help improve debugging but the application is starting to take shape.</p>

<p><strong>Notes</strong></p>

<pre><code>window = Tk()
window.title(&#39;Maths Application&#39;)
window.geometry(&#34;570x150&#34;) # w x h
window.resizable(0,0)
</code></pre>
<ol><li><p>The above code is being modified as I go. So I am changing the window size depending on what is being displayed.</p></li>

<li><p>I have also made the Window title reflect the purpose of the application.</p></li>

<li><p>That the source code now has &#39;result&#39; as a label rather than output.  This will show up future screenshots.</p></li></ol>

<p><img src="https://raw.githubusercontent.com/zleap/blogmedia/master/tkinter/AdditionApp2.png" alt="addition app"></p>

<p>The code for the above is as follows.</p>

<pre><code>#!/usr/bin/env python
import Tkinter # note use of caps
from Tkinter import *

window = Tk()
window.title(&#39;Maths Application&#39;)
window.geometry(&#34;570x150&#34;) # w x h
window.resizable(0,0)

#define button actions
def btn1():
	#convert box text in to integers	
	ent1 = int(entrytext.get())
	ent2 = int(entrytext2.get())
	
	#add the 2 integers and store in variable add
	add = (ent1 + ent2)
	print (add)
	
	#insert value of variable add in	to box outtext 
	outtext1.insert(0,str(add)) # insert response

def btn2():
	#print(&#34;subtraction&#34;)
	ent1 = int(entrytext.get())
	ent2 = int(entrytext2.get())
	
	#subtract the 2 integers and store in variable sub
	sub = (ent1 - ent2)
	
	
	#insert value of variable sub in	to box outtext 
	outtext1.insert(0,str(sub)) # insert response	
	
def btn3():
	#print(&#34;multiply&#34;)
	ent1 = int(entrytext.get())
	ent2 = int(entrytext2.get())
	
	#multiply the 2 integers and store in variable mul
	mul = (ent1 * ent2)
		
	#insert value of variable mul in	to box outtext 
	outtext1.insert(0,str(mul)) # insert response		

def btn4():
	#print(&#34;divide&#34;)
	ent1 = int(entrytext.get())
	ent2 = int(entrytext2.get())
	
	#multiply the 2 integers and store in variable div
	div = (ent1 / ent2)
		
	#insert value of variable mul in	to box outtext 
	outtext1.insert(0,str(div)) # insert response	
	
#clear boxes
def clear():
	#print(&#34;clear boxes&#34;) # leave in for legacy testing
	entrytext.delete(0, END) # clear input box
	entrytext2.delete(0, END) # clear input box2
	outtext1.delete(0, END) # clear output box
	
btn_tog2 = Button( window, text =&#39;+&#39;, command=btn1) # add
btn_tog3 = Button( window, text =&#39;-&#39;, command=btn2)  # subtract
btn_tog4 = Button( window, text =&#39;x&#39;, command=btn3) #multiply
btn_tog5 = Button( window, text =&#39;/&#39;, command=btn4) #divide
btn_tog6 = Button( window, text =&#39;Clear&#39;, command=clear) #clear
btn_exit = Button( window, text =&#39;Exit&#39;,command=exit)	 #exit

# define some labels
box1 = Label(window, text=&#34;1st Value&#34;)
box2 = Label(window, text=&#34;2nd Value&#34;)
box3 = Label(window, text=&#34;Result&#34;)

#define entry box 
entry1 = StringVar() # this is our entry box
entry2 = StringVar()
entrytext = Entry(window, textvariable=entry1) # this is our entry box
entrytext2 = Entry(window, textvariable=entry2) # this is our second entry box

#define out box 

entry2 = StringVar() # this is our output box
outtext1 = Entry(window, textvariable=entry2) # this is our output box

#display boxes
entrytext.grid(row = 3, column = 2,)  #display entry box
entrytext2.grid(row = 3, column = 3,)  #display entry box
outtext1.grid(row = 3, column = 4,) #display output box

#place labels
box1.grid(row = 1	, column = 2, padx = 5, pady = 5)
box2.grid(row = 1	, column = 3, padx = 5, pady = 5)
box3.grid(row = 1	, column = 4, padx = 5, pady = 5)

#buttons
btn_tog2.grid(row = 4, column = 2, padx = 1, pady = 1) # addition button
btn_tog3.grid(row = 4, column = 3, padx = 1, pady = 1) # subtraction button
btn_tog4.grid(row = 5, column = 2, padx = 1, pady = 1) # multiply button
btn_tog5.grid(row = 5, column = 3, padx = 1, pady = 1) # divide button
btn_tog6.grid(row = 4, column = 6, padx = 1, pady = 1) # clear button
btn_exit.grid(row = 3, column = 6, padx = 1, pady = 1) # exit button

window.mainloop()


</code></pre>

<p>The code that I used for a previous application to detect if numerical values have been used is below but provided &#39;as is&#39; for now.</p>

<pre><code>def response():
		
	msg = &#34;error : must be a text value&#34;

	i = circletext.get()
	y = i.isdigit()
	l = len(circletext.get())
	#print l
	if y == True or l == 0:
		circletext.insert(0,(msg))
		
	else:	
		x = random.choice(RESPONSES)
		circletext2.delete(0, END) # clear prev output
		circletext2.insert(0,str(x)) # insert response
</code></pre>

<p>I will integrate a version of this in to the main code.</p>

<p><a href="/paulsutton/tag:python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">python</span></a>, <a href="/paulsutton/tag:tkinter" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">tkinter</span></a>, <a href="/paulsutton/tag:programming" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">programming</span></a>, <a href="/paulsutton/tag:python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">python</span></a>, <a href="/paulsutton/tag:graphic" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">graphic</span></a>, <a href="/paulsutton/tag:applications" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">applications</span></a>, <a href="/paulsutton/tag:bugs" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">bugs</span></a>, <a href="/paulsutton/tag:troubleshooting" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">troubleshooting</span></a>, <a href="/paulsutton/tag:howto" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">howto</span></a>, <a href="/paulsutton/tag:paignton" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">paignton</span></a>, <a href="/paulsutton/tag:library" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">library</span></a>, <a href="/paulsutton/tag:virtual" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">virtual</span></a>, <a href="/paulsutton/tag:codeclub" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">codeclub</span></a></p>

<p>Happy to provide help and support via decentralised social media.  I can be contacted on Mastodon <a href="https://qoto.org/@zleap/" rel="nofollow">here</a>. You can get a free account on the <a href="http://qoto.org" rel="nofollow">http://qoto.org</a> instance by following <a href="https://qoto.org/invite/pN8gdTzi" rel="nofollow">this link</a>.</p>

<p><img src="https://raw.githubusercontent.com/zleap/blogmedia/master/88x31.png" alt="cc-by logo"></p>

<p><a href="https://creativecommons.org/licenses/by/4.0/" rel="nofollow">Licenced under Attribution 4.0 International (CC BY 4.0)</a></p>

<hr>

<p><table>
<thead>
<tr><td><a href="https://qoto.org/@zleap" rel="nofollow">Mastodon</a></td>
<td><a href="https://wiki.ircnow.org/?n=Shelllabs.Intro" rel="nofollow">ShellLabs</td>
<td><a href="https://joinmastodon.org/" rel="nofollow">Join Mastodon</a></td></tr></thead></table>

AI statement : <b> Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. </b>
</p>

<p><a href="https://liberapay.com/PaulSutton/donate" rel="nofollow"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></p>
]]></content:encoded>
      <guid>https://personaljournal.ca/paulsutton/add-more-functions</guid>
      <pubDate>Thu, 21 May 2020 06:44:22 +0000</pubDate>
    </item>
    <item>
      <title>Addition Application</title>
      <link>https://personaljournal.ca/paulsutton/addition-application</link>
      <description>&lt;![CDATA[Addition Application&#xA;&#xA;So following on from the previous posts, I am how sharing a small application, that makes use of what we have been learning. &#xA;&#xA;This presents 2 input boxes and an output box,  any values entered in to the first two,  the sum is placed in to the last box.&#xA;&#xA;addition app&#xA;&#xA;This is not perfect, but getting there slowly.&#xA;&#xA;We need to:-&#xA;&#xA;Fix the name of the button from button1&#xA;Detect if the user has entered numerical values&#xA;Detect for empty boxes&#xA;Make labels more useful&#xA;Fix spelling in comments&#xA;Fix clarity of comments&#xA;&#xA;The code for the above is as follows. &#xA;&#xA;!/usr/bin/env python&#xA;import Tkinter # note use of caps&#xA;from Tkinter import *&#xA;&#xA;window = Tk()&#xA;window.title(&#39;App 1&#39;)&#xA;window.geometry(&#34;650x125&#34;) # w x h&#xA;window.resizable(0,0)&#xA;&#xA;define button actions&#xA;def btn1():&#xA;&#x9;#convert box text in to integers&#x9;&#xA;&#x9;ent1 = int(entrytext.get())&#xA;&#x9;ent2 = int(entrytext2.get())&#xA;&#x9;&#xA;&#x9;#add the 2 integers and store in variable add&#xA;&#x9;add = (ent1 + ent2)&#xA;&#x9;print add&#xA;&#x9;&#xA;&#x9;#instert value add in&#x9;to box outtext &#xA;&#x9;outtext1.insert(0,str(add)) # insert response&#xA;&#x9;&#xA;btntog2 = Button( window, text =&#39;button1&#39;, command=btn1)&#xA;btnexit = Button( window, text =&#39;exit&#39;,command=exit)&#x9;&#xA;&#xA;define some labels&#xA;box1 = Label(window, text=&#34;Entry 1: &#34;)&#xA;box2 = Label(window, text=&#34;Entry 2: &#34;)&#xA;box3 = Label(window, text=&#34;Ouput1: &#34;)&#xA;&#xA;define entry box &#xA;entry1 = StringVar() # this is our entry box&#xA;entry2 = StringVar()&#xA;entrytext = Entry(window, textvariable=entry1) # this is our entry box&#xA;entrytext2 = Entry(window, textvariable=entry2) # this is our second entry box&#xA;&#xA;define out box &#xA;&#xA;entry2 = StringVar() # this is our output box&#xA;outtext1 = Entry(window, textvariable=entry2) # this is our output box&#xA;&#xA;display boxes&#xA;entrytext.grid(row = 3, column = 2,)  #display entry box&#xA;entrytext2.grid(row = 3, column = 3,)  #display entry box&#xA;outtext1.grid(row = 3, column = 4,) #display output box&#xA;&#xA;place labels&#xA;box1.grid(row = 1&#x9;, column = 2, padx = 5, pady = 5)&#xA;box2.grid(row = 1&#x9;, column = 3, padx = 5, pady = 5)&#xA;box3.grid(row = 1&#x9;, column = 4, padx = 5, pady = 5)&#xA;&#xA;buttons&#xA;btntog2.grid(row = 3, column = 5, padx = 5, pady = 5)&#xA;btnexit.grid(row = 3, column = 6, padx = 5, pady = 5)&#xA;&#xA;window.mainloop()&#xA;&#xA;#python, #tkinter, #programming, #python, #graphic, #applications, #bugs, #troubleshooting, #howto, #paignton, #library, #virtual, #codeclub&#xA;&#xA;Happy to provide help and support via decentralised social media.  I can be contacted on Mastodon here. You can get a free account on the http://qoto.org instance by following this link.&#xA;&#xA;cc-by logo&#xA;&#xA;Licenced under Attribution 4.0 International (CC BY 4.0)&#xA;&#xA;hr&#xD;&#xA;&#xD;&#xA;table&#xD;&#xA;thead&#xD;&#xA;trtda rel=&#34;me&#34; href=&#34;https://qoto.org/@zleap&#34;Mastodon/a/td&#xD;&#xA;tda href=&#34;https://wiki.ircnow.org/?n=Shelllabs.Intro&#34;ShellLabs/td&#xD;&#xA;tda href=&#34;https://joinmastodon.org/&#34;Join Mastodon/a/td/tr/thead/table&#xD;&#xA;center&#xD;&#xA;AI statement : b Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. /b&#xD;&#xA;/center&#xD;&#xA;&#xD;&#xA;a href=&#34;https://liberapay.com/PaulSutton/donate&#34;img alt=&#34;Donate using Liberapay&#34; src=&#34;https://liberapay.com/assets/widgets/donate.svg&#34;/a&#xD;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Addition Application</p>

<p>So following on from the previous posts, I am how sharing a small application, that makes use of what we have been learning.</p>

<p>This presents 2 input boxes and an output box,  any values entered in to the first two,  the sum is placed in to the last box.</p>

<p><img src="https://raw.githubusercontent.com/zleap/blogmedia/master/tkinter/AdditionApp.png" alt="addition app"></p>

<p>This is not perfect, but getting there slowly.</p>

<p>We need to:-</p>
<ul><li>Fix the name of the button from button1</li>
<li>Detect if the user has entered numerical values</li>
<li>Detect for empty boxes</li>
<li>Make labels more useful</li>
<li>Fix spelling in comments</li>
<li>Fix clarity of comments</li></ul>

<p>The code for the above is as follows.</p>

<pre><code>#!/usr/bin/env python
import Tkinter # note use of caps
from Tkinter import *

window = Tk()
window.title(&#39;App 1&#39;)
window.geometry(&#34;650x125&#34;) # w x h
window.resizable(0,0)

#define button actions
def btn1():
	#convert box text in to integers	
	ent1 = int(entrytext.get())
	ent2 = int(entrytext2.get())
	
	#add the 2 integers and store in variable add
	add = (ent1 + ent2)
	print add
	
	#instert value add in	to box outtext 
	outtext1.insert(0,str(add)) # insert response
	
btn_tog2 = Button( window, text =&#39;button1&#39;, command=btn1)
btn_exit = Button( window, text =&#39;exit&#39;,command=exit)	

# define some labels
box1 = Label(window, text=&#34;Entry 1: &#34;)
box2 = Label(window, text=&#34;Entry 2: &#34;)
box3 = Label(window, text=&#34;Ouput1: &#34;)

#define entry box 
entry1 = StringVar() # this is our entry box
entry2 = StringVar()
entrytext = Entry(window, textvariable=entry1) # this is our entry box
entrytext2 = Entry(window, textvariable=entry2) # this is our second entry box

#define out box 

entry2 = StringVar() # this is our output box
outtext1 = Entry(window, textvariable=entry2) # this is our output box

#display boxes
entrytext.grid(row = 3, column = 2,)  #display entry box
entrytext2.grid(row = 3, column = 3,)  #display entry box
outtext1.grid(row = 3, column = 4,) #display output box

#place labels
box1.grid(row = 1	, column = 2, padx = 5, pady = 5)
box2.grid(row = 1	, column = 3, padx = 5, pady = 5)
box3.grid(row = 1	, column = 4, padx = 5, pady = 5)

#buttons
btn_tog2.grid(row = 3, column = 5, padx = 5, pady = 5)
btn_exit.grid(row = 3, column = 6, padx = 5, pady = 5)

window.mainloop()

</code></pre>

<p><a href="/paulsutton/tag:python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">python</span></a>, <a href="/paulsutton/tag:tkinter" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">tkinter</span></a>, <a href="/paulsutton/tag:programming" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">programming</span></a>, <a href="/paulsutton/tag:python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">python</span></a>, <a href="/paulsutton/tag:graphic" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">graphic</span></a>, <a href="/paulsutton/tag:applications" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">applications</span></a>, <a href="/paulsutton/tag:bugs" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">bugs</span></a>, <a href="/paulsutton/tag:troubleshooting" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">troubleshooting</span></a>, <a href="/paulsutton/tag:howto" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">howto</span></a>, <a href="/paulsutton/tag:paignton" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">paignton</span></a>, <a href="/paulsutton/tag:library" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">library</span></a>, <a href="/paulsutton/tag:virtual" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">virtual</span></a>, <a href="/paulsutton/tag:codeclub" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">codeclub</span></a></p>

<p>Happy to provide help and support via decentralised social media.  I can be contacted on Mastodon <a href="https://qoto.org/@zleap/" rel="nofollow">here</a>. You can get a free account on the <a href="http://qoto.org" rel="nofollow">http://qoto.org</a> instance by following <a href="https://qoto.org/invite/pN8gdTzi" rel="nofollow">this link</a>.</p>

<p><img src="https://raw.githubusercontent.com/zleap/blogmedia/master/88x31.png" alt="cc-by logo"></p>

<p><a href="https://creativecommons.org/licenses/by/4.0/" rel="nofollow">Licenced under Attribution 4.0 International (CC BY 4.0)</a></p>

<hr>

<p><table>
<thead>
<tr><td><a href="https://qoto.org/@zleap" rel="nofollow">Mastodon</a></td>
<td><a href="https://wiki.ircnow.org/?n=Shelllabs.Intro" rel="nofollow">ShellLabs</td>
<td><a href="https://joinmastodon.org/" rel="nofollow">Join Mastodon</a></td></tr></thead></table>

AI statement : <b> Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. </b>
</p>

<p><a href="https://liberapay.com/PaulSutton/donate" rel="nofollow"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></p>
]]></content:encoded>
      <guid>https://personaljournal.ca/paulsutton/addition-application</guid>
      <pubDate>Wed, 20 May 2020 06:30:00 +0000</pubDate>
    </item>
    <item>
      <title>More improvements</title>
      <link>https://personaljournal.ca/paulsutton/more-improvements</link>
      <description>&lt;![CDATA[More improvements &#xA;&#xA;Adding labels &#xA;&#xA;So last time we added some text boxes and made the application a little more presentable.  Now we are going to do is add some labels above the boxes to help describe what they do.   &#xA;&#xA;Add this above were we define the entry boxes&#xA;&#xA;define some labels&#xA;box1 = Label(window, text=&#34;Entry 1: &#34;)&#xA;box2 = Label(window, text=&#34;Entry 2: &#34;)&#xA;box3 = Label(window, text=&#34;Ouput1: &#34;)&#xA;&#xA;Now add this below where we place the entry boxes but above window.mainloop()&#xA;&#xA;place labels&#xA;box1.grid(row = 1&#x9;, column = 2, padx = 5, pady = 5)&#xA;box2.grid(row = 1&#x9;, column = 3, padx = 5, pady = 5)&#xA;box3.grid(row = 1&#x9;, column = 4, padx = 5, pady = 5)&#xA;&#xA;So here we have a window, with three text boxes. &#xA;&#xA;app1 &#xA;&#xA;So again we have something that looks a little more like an application.&#xA;&#xA;#tkinter,#python,#gui,#programming.&#xA;&#xA;hr&#xD;&#xA;&#xD;&#xA;table&#xD;&#xA;thead&#xD;&#xA;trtda rel=&#34;me&#34; href=&#34;https://qoto.org/@zleap&#34;Mastodon/a/td&#xD;&#xA;tda href=&#34;https://wiki.ircnow.org/?n=Shelllabs.Intro&#34;ShellLabs/td&#xD;&#xA;tda href=&#34;https://joinmastodon.org/&#34;Join Mastodon/a/td/tr/thead/table&#xD;&#xA;center&#xD;&#xA;AI statement : b Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. /b&#xD;&#xA;/center&#xD;&#xA;&#xD;&#xA;a href=&#34;https://liberapay.com/PaulSutton/donate&#34;img alt=&#34;Donate using Liberapay&#34; src=&#34;https://liberapay.com/assets/widgets/donate.svg&#34;/a&#xD;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>More improvements</p>

<p>Adding labels</p>

<p>So last time we added some text boxes and made the application a little more presentable.  Now we are going to do is add some labels above the boxes to help describe what they do.</p>

<p>Add this above were we define the entry boxes</p>

<pre><code># define some labels
box1 = Label(window, text=&#34;Entry 1: &#34;)
box2 = Label(window, text=&#34;Entry 2: &#34;)
box3 = Label(window, text=&#34;Ouput1: &#34;)

</code></pre>

<p>Now add this below where we place the entry boxes but above <strong>window.mainloop()</strong></p>

<pre><code>#place labels
box1.grid(row = 1	, column = 2, padx = 5, pady = 5)
box2.grid(row = 1	, column = 3, padx = 5, pady = 5)
box3.grid(row = 1	, column = 4, padx = 5, pady = 5)
</code></pre>

<p>So here we have a window, with three text boxes.</p>

<p><img src="https://raw.githubusercontent.com/zleap/blogmedia/master/tkinter/app2.png" alt="app1"></p>

<p>So again we have something that looks a little more like an application.</p>

<p><a href="/paulsutton/tag:tkinter" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">tkinter</span></a>,<a href="/paulsutton/tag:python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">python</span></a>,<a href="/paulsutton/tag:gui" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">gui</span></a>,<a href="/paulsutton/tag:programming" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">programming</span></a>.</p>

<hr>

<p><table>
<thead>
<tr><td><a href="https://qoto.org/@zleap" rel="nofollow">Mastodon</a></td>
<td><a href="https://wiki.ircnow.org/?n=Shelllabs.Intro" rel="nofollow">ShellLabs</td>
<td><a href="https://joinmastodon.org/" rel="nofollow">Join Mastodon</a></td></tr></thead></table>

AI statement : <b> Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. </b>
</p>

<p><a href="https://liberapay.com/PaulSutton/donate" rel="nofollow"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></p>
]]></content:encoded>
      <guid>https://personaljournal.ca/paulsutton/more-improvements</guid>
      <pubDate>Tue, 19 May 2020 06:30:00 +0000</pubDate>
    </item>
    <item>
      <title>Tidying up our application</title>
      <link>https://personaljournal.ca/paulsutton/tidying-up-our-application</link>
      <description>&lt;![CDATA[Tidying up our application&#xA;&#xA;So my last post produced something that did not really look very good.  So I have now tidied the code up a little bit to make it look better.&#xA;&#xA;So one of the useful things within this is to adjust the dimensions of our application, so everything fits in to the window area nicely, but not leave too much empty space. &#xA;&#xA;!/usr/bin/env python&#xA;import Tkinter # note use of caps&#xA;from Tkinter import *&#xA;&#xA;window = Tk()&#xA;window.title(&#39;App 1&#39;)&#xA;window.geometry(&#34;600x50&#34;) # w x h&#xA;window.resizable(0,0)&#xA;&#xA;define entry box &#xA;&#xA;entry1 = StringVar() # this is our entry box&#xA;entrytext = Entry(window, textvariable=entry1) # this is our entry box&#xA;entrytext2 = Entry(window, textvariable=entry1) # this is our second entry box&#xA;define out box &#xA;&#xA;entry2 = StringVar() # this is our output box&#xA;outtext1 = Entry(window, textvariable=entry2) # this is our output box&#xA;&#xA;display boxes&#xA;entrytext.grid(row = 3, column = 2,)  #display entry box&#xA;entrytext2.grid(row = 3, column = 3,)  #display entry box&#xA;outtext1.grid(row = 3, column = 4,) #display output box&#xA;&#xA;window.mainloop()&#xA;&#xA;So here we have a window, with three text boxes. &#xA;&#xA;app1 &#xA;&#xA;Which is starting to look a little better.  The main bit of advice I can give here, is test, test and test again, that way you know your application is working as you go. &#xA;&#xA;#tkinter,#python,#gui,#programming.&#xA;&#xA;hr&#xD;&#xA;&#xD;&#xA;table&#xD;&#xA;thead&#xD;&#xA;trtda rel=&#34;me&#34; href=&#34;https://qoto.org/@zleap&#34;Mastodon/a/td&#xD;&#xA;tda href=&#34;https://wiki.ircnow.org/?n=Shelllabs.Intro&#34;ShellLabs/td&#xD;&#xA;tda href=&#34;https://joinmastodon.org/&#34;Join Mastodon/a/td/tr/thead/table&#xD;&#xA;center&#xD;&#xA;AI statement : b Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. /b&#xD;&#xA;/center&#xD;&#xA;&#xD;&#xA;a href=&#34;https://liberapay.com/PaulSutton/donate&#34;img alt=&#34;Donate using Liberapay&#34; src=&#34;https://liberapay.com/assets/widgets/donate.svg&#34;/a&#xD;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Tidying up our application</p>

<p>So my last post produced something that did not really look very good.  So I have now tidied the code up a little bit to make it look better.</p>

<p>So one of the useful things within this is to adjust the dimensions of our application, so everything fits in to the window area nicely, but not leave too much empty space.</p>

<pre><code>#!/usr/bin/env python
import Tkinter # note use of caps
from Tkinter import *

window = Tk()
window.title(&#39;App 1&#39;)
window.geometry(&#34;600x50&#34;) # w x h
window.resizable(0,0)

#define entry box 

entry1 = StringVar() # this is our entry box
entrytext = Entry(window, textvariable=entry1) # this is our entry box
entrytext2 = Entry(window, textvariable=entry1) # this is our second entry box
#define out box 

entry2 = StringVar() # this is our output box
outtext1 = Entry(window, textvariable=entry2) # this is our output box


#display boxes
entrytext.grid(row = 3, column = 2,)  #display entry box
entrytext2.grid(row = 3, column = 3,)  #display entry box
outtext1.grid(row = 3, column = 4,) #display output box


window.mainloop()

</code></pre>

<p>So here we have a window, with three text boxes.</p>

<p><img src="https://raw.githubusercontent.com/zleap/blogmedia/master/tkinter/app1.png" alt="app1"></p>

<p>Which is starting to look a little better.  The main bit of advice I can give here, is <strong>test, test and test again</strong>, that way you know your application is working as you go.</p>

<p><a href="/paulsutton/tag:tkinter" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">tkinter</span></a>,<a href="/paulsutton/tag:python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">python</span></a>,<a href="/paulsutton/tag:gui" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">gui</span></a>,<a href="/paulsutton/tag:programming" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">programming</span></a>.</p>

<hr>

<p><table>
<thead>
<tr><td><a href="https://qoto.org/@zleap" rel="nofollow">Mastodon</a></td>
<td><a href="https://wiki.ircnow.org/?n=Shelllabs.Intro" rel="nofollow">ShellLabs</td>
<td><a href="https://joinmastodon.org/" rel="nofollow">Join Mastodon</a></td></tr></thead></table>

AI statement : <b> Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. </b>
</p>

<p><a href="https://liberapay.com/PaulSutton/donate" rel="nofollow"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></p>
]]></content:encoded>
      <guid>https://personaljournal.ca/paulsutton/tidying-up-our-application</guid>
      <pubDate>Mon, 18 May 2020 06:30:00 +0000</pubDate>
    </item>
    <item>
      <title>More tkinter : Add entry and text box</title>
      <link>https://personaljournal.ca/paulsutton/more-tkinter-add-entry-and-text-box</link>
      <description>&lt;![CDATA[More tkinter : Add entry and text box&#xA;&#xA;This code adds a box to our application, a box can serve either as a text output box OR a text entry box.&#xA;&#xA;Note I have included the whole program here.  I have also defined the size of our application.  &#xA;&#xA;While the window is bigger and the boxes are at the top, the idea is that it just displays those boxes.  We can tidy things up later. &#xA;&#xA;!/usr/bin/env python&#xA;import Tkinter # note use of caps&#xA;from Tkinter import *&#xA;&#xA;window = Tk()&#xA;window.title(&#39;GUI Tkinter 1&#39;)&#xA;window.geometry(&#34;300x250&#34;) # w x h&#xA;window.resizable(0,0)&#xA;&#xA;define entry box &#xA;&#xA;circleVar = StringVar()&#xA;circletext = Entry(window, textvariable=circleVar)&#xA;&#xA;define out box &#xA;&#xA;circleVar2 = StringVar()&#xA;circletext2 = Entry(window, textvariable=circleVar2)&#xA;&#xA;circleVar2 = StringVar()&#xA;circletext2 = Entry(window, textvariable=circleVar2)&#xA;&#xA;display boxes&#xA;circletext.grid(row = 1, column = 2,)&#xA;circletext2.grid(row = 2, column = 2,)&#xA;&#xA;window.mainloop()&#xA;&#xA;We get:&#xA;&#xA;tk label&#xA;&#xA;#tkinter,#python,#gui,#programming. &#xA;&#xA;hr&#xD;&#xA;&#xD;&#xA;table&#xD;&#xA;thead&#xD;&#xA;trtda rel=&#34;me&#34; href=&#34;https://qoto.org/@zleap&#34;Mastodon/a/td&#xD;&#xA;tda href=&#34;https://wiki.ircnow.org/?n=Shelllabs.Intro&#34;ShellLabs/td&#xD;&#xA;tda href=&#34;https://joinmastodon.org/&#34;Join Mastodon/a/td/tr/thead/table&#xD;&#xA;center&#xD;&#xA;AI statement : b Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. /b&#xD;&#xA;/center&#xD;&#xA;&#xD;&#xA;a href=&#34;https://liberapay.com/PaulSutton/donate&#34;img alt=&#34;Donate using Liberapay&#34; src=&#34;https://liberapay.com/assets/widgets/donate.svg&#34;/a&#xD;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>More tkinter : Add entry and text box</p>

<p>This code adds a box to our application, a box can serve either as a text output box OR a text entry box.</p>

<p>Note I have included the whole program here.  I have also defined the size of our application.</p>

<p>While the window is bigger and the boxes are at the top, the idea is that it just displays those boxes.  We can tidy things up later.</p>

<pre><code>#!/usr/bin/env python
import Tkinter # note use of caps
from Tkinter import *

window = Tk()
window.title(&#39;GUI Tkinter 1&#39;)
window.geometry(&#34;300x250&#34;) # w x h
window.resizable(0,0)

#define entry box 

circleVar = StringVar()
circletext = Entry(window, textvariable=circleVar)

#define out box 

circleVar2 = StringVar()
circletext2 = Entry(window, textvariable=circleVar2)

circleVar2 = StringVar()
circletext2 = Entry(window, textvariable=circleVar2)


#display boxes
circletext.grid(row = 1, column = 2,)
circletext2.grid(row = 2, column = 2,)


window.mainloop()

</code></pre>

<p>We get:</p>

<p><img src="https://raw.githubusercontent.com/zleap/blogmedia/master/tkinter/boxes.png" alt="tk label"></p>

<p><a href="/paulsutton/tag:tkinter" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">tkinter</span></a>,<a href="/paulsutton/tag:python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">python</span></a>,<a href="/paulsutton/tag:gui" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">gui</span></a>,<a href="/paulsutton/tag:programming" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">programming</span></a>.</p>

<hr>

<p><table>
<thead>
<tr><td><a href="https://qoto.org/@zleap" rel="nofollow">Mastodon</a></td>
<td><a href="https://wiki.ircnow.org/?n=Shelllabs.Intro" rel="nofollow">ShellLabs</td>
<td><a href="https://joinmastodon.org/" rel="nofollow">Join Mastodon</a></td></tr></thead></table>

AI statement : <b> Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. </b>
</p>

<p><a href="https://liberapay.com/PaulSutton/donate" rel="nofollow"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></p>
]]></content:encoded>
      <guid>https://personaljournal.ca/paulsutton/more-tkinter-add-entry-and-text-box</guid>
      <pubDate>Sun, 17 May 2020 06:30:00 +0000</pubDate>
    </item>
    <item>
      <title>More tkinter : Combine buttons and labels.</title>
      <link>https://personaljournal.ca/paulsutton/more-tkinter-combine-buttons-and-labels</link>
      <description>&lt;![CDATA[More tkinter : Combine buttons and labels.&#xA;&#xA;Now that we can add a label and a button, it is time to combine the two.  The following code does this. &#xA;&#xA;define functions for button(s)&#xA;def btn1():&#xA;&#x9;print (&#34;button pressed&#34;)&#xA;&#x9;&#xA;&#x9;&#xA;create button object&#x9;&#xA;btntog2 = Button( window, text =&#39;button1&#39;, command=btn1)&#xA;btnexit = Button( window, text =&#39;exit&#39;,command=exit)&#x9;&#xA;&#xA;place button object&#xA;btntog2.grid(row = 1, column = 2, padx = 5, pady = 5)&#xA;btnexit.grid(row = 2, column = 2, padx = 5, pady = 5)&#xA;&#xA;define labeles&#xA;button1 = Label(window, text=&#34;press button&#34;)&#xA;button2 = Label(window, text=&#34;exit program&#34;)&#xA;&#xA;place labels&#xA;button1.grid(row = 1, column = 1, padx = 5, pady = 5)&#xA;button2.grid(row = 2, column = 1, padx = 5, pady = 5)&#xA;&#xA;We get:&#xA;&#xA;tk label&#xA;&#xA;#tkinter,#python,#gui,#programming. &#xA;&#xA;hr&#xD;&#xA;&#xD;&#xA;table&#xD;&#xA;thead&#xD;&#xA;trtda rel=&#34;me&#34; href=&#34;https://qoto.org/@zleap&#34;Mastodon/a/td&#xD;&#xA;tda href=&#34;https://wiki.ircnow.org/?n=Shelllabs.Intro&#34;ShellLabs/td&#xD;&#xA;tda href=&#34;https://joinmastodon.org/&#34;Join Mastodon/a/td/tr/thead/table&#xD;&#xA;center&#xD;&#xA;AI statement : b Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. /b&#xD;&#xA;/center&#xD;&#xA;&#xD;&#xA;a href=&#34;https://liberapay.com/PaulSutton/donate&#34;img alt=&#34;Donate using Liberapay&#34; src=&#34;https://liberapay.com/assets/widgets/donate.svg&#34;/a&#xD;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>More tkinter : Combine buttons and labels.</p>

<p>Now that we can add a label and a button, it is time to combine the two.  The following code does this.</p>

<pre><code>#define functions for button(s)
def btn1():
	print (&#34;button pressed&#34;)
	
	
#create button object	
btn_tog2 = Button( window, text =&#39;button1&#39;, command=btn1)
btn_exit = Button( window, text =&#39;exit&#39;,command=exit)	

#place button object
btn_tog2.grid(row = 1, column = 2, padx = 5, pady = 5)
btn_exit.grid(row = 2, column = 2, padx = 5, pady = 5)

#define labeles
button1 = Label(window, text=&#34;press button&#34;)
button2 = Label(window, text=&#34;exit program&#34;)

#place labels
button1.grid(row = 1, column = 1, padx = 5, pady = 5)
button2.grid(row = 2, column = 1, padx = 5, pady = 5)
</code></pre>

<p>We get:</p>

<p><img src="https://raw.githubusercontent.com/zleap/blogmedia/master/tkinter/tk4.png" alt="tk label"></p>

<p><a href="/paulsutton/tag:tkinter" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">tkinter</span></a>,<a href="/paulsutton/tag:python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">python</span></a>,<a href="/paulsutton/tag:gui" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">gui</span></a>,<a href="/paulsutton/tag:programming" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">programming</span></a>.</p>

<hr>

<p><table>
<thead>
<tr><td><a href="https://qoto.org/@zleap" rel="nofollow">Mastodon</a></td>
<td><a href="https://wiki.ircnow.org/?n=Shelllabs.Intro" rel="nofollow">ShellLabs</td>
<td><a href="https://joinmastodon.org/" rel="nofollow">Join Mastodon</a></td></tr></thead></table>

AI statement : <b> Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. </b>
</p>

<p><a href="https://liberapay.com/PaulSutton/donate" rel="nofollow"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></p>
]]></content:encoded>
      <guid>https://personaljournal.ca/paulsutton/more-tkinter-combine-buttons-and-labels</guid>
      <pubDate>Sat, 16 May 2020 06:30:00 +0000</pubDate>
    </item>
    <item>
      <title>More tkinter : Adding buttons</title>
      <link>https://personaljournal.ca/paulsutton/more-tkinter-adding-buttons</link>
      <description>&lt;![CDATA[More tkinter : Adding buttons&#xA;&#xA;So to carry on with some basic tk development, Once we can add a label, we add buttons.  While buttons have a built in label,  the label widget could be useful to add more description to that area of the application.&#xA;&#xA;def btn1():&#xA;&#x9;print (&#34;button pressed&#34;)&#xA;&#x9;&#xA;btntog2 = Button( window, text =&#39;button1&#39;, command=btn1)&#xA;btnexit = Button( window, text =&#39;exit&#39;,command=exit)&#x9;&#xA;&#xA;btntog2.grid(row = 1, column = 1, padx = 5, pady = 5)&#xA;btnexit.grid(row = 2, column = 1, padx = 5, pady = 5)&#xA;&#xA;We get:&#xA;&#xA;tk label&#xA;&#xA;With this we have added an event, so in this case the btn_tog2 runs the function btn1 which prints &#34;button pressed&#34; to the console. &#xA;&#xA;#tkinter,#python,#gui,#programming. &#xA;&#xA;hr&#xD;&#xA;&#xD;&#xA;table&#xD;&#xA;thead&#xD;&#xA;trtda rel=&#34;me&#34; href=&#34;https://qoto.org/@zleap&#34;Mastodon/a/td&#xD;&#xA;tda href=&#34;https://wiki.ircnow.org/?n=Shelllabs.Intro&#34;ShellLabs/td&#xD;&#xA;tda href=&#34;https://joinmastodon.org/&#34;Join Mastodon/a/td/tr/thead/table&#xD;&#xA;center&#xD;&#xA;AI statement : b Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. /b&#xD;&#xA;/center&#xD;&#xA;&#xD;&#xA;a href=&#34;https://liberapay.com/PaulSutton/donate&#34;img alt=&#34;Donate using Liberapay&#34; src=&#34;https://liberapay.com/assets/widgets/donate.svg&#34;/a&#xD;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>More tkinter : Adding buttons</p>

<p>So to carry on with some basic tk development, Once we can add a label, we add buttons.  While buttons have a built in label,  the label widget could be useful to add more description to that area of the application.</p>

<pre><code>def btn1():
	print (&#34;button pressed&#34;)
	
btn_tog2 = Button( window, text =&#39;button1&#39;, command=btn1)
btn_exit = Button( window, text =&#39;exit&#39;,command=exit)	


btn_tog2.grid(row = 1, column = 1, padx = 5, pady = 5)
btn_exit.grid(row = 2, column = 1, padx = 5, pady = 5)
</code></pre>

<p>We get:</p>

<p><img src="https://raw.githubusercontent.com/zleap/blogmedia/master/tkinter/tk3.png" alt="tk label"></p>

<p>With this we have added an event, so in this case the <strong>btn_tog2</strong> runs the function <strong>btn1</strong> which prints “button pressed” to the console.</p>

<p><a href="/paulsutton/tag:tkinter" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">tkinter</span></a>,<a href="/paulsutton/tag:python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">python</span></a>,<a href="/paulsutton/tag:gui" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">gui</span></a>,<a href="/paulsutton/tag:programming" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">programming</span></a>.</p>

<hr>

<p><table>
<thead>
<tr><td><a href="https://qoto.org/@zleap" rel="nofollow">Mastodon</a></td>
<td><a href="https://wiki.ircnow.org/?n=Shelllabs.Intro" rel="nofollow">ShellLabs</td>
<td><a href="https://joinmastodon.org/" rel="nofollow">Join Mastodon</a></td></tr></thead></table>

AI statement : <b> Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. </b>
</p>

<p><a href="https://liberapay.com/PaulSutton/donate" rel="nofollow"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></p>
]]></content:encoded>
      <guid>https://personaljournal.ca/paulsutton/more-tkinter-adding-buttons</guid>
      <pubDate>Fri, 15 May 2020 06:30:00 +0000</pubDate>
    </item>
    <item>
      <title>More tkinter development</title>
      <link>https://personaljournal.ca/paulsutton/more-tkinter-development</link>
      <description>&lt;![CDATA[More tkinter development&#xA;&#xA;So further to yesterdays post&#xA;&#xA;The next step is to add some widgets to our application. It is generally useful to label any items.  That way a user knows what purpose an entry box has. &#xA;&#xA;If we take the code block from yesterday and add &#xA;&#xA;define labeles&#xA;box1 = Label(window, text=&#34;Entry 1: &#34;)&#xA;&#xA;place labels&#xA;box1.grid(row = 1, column = 1, padx = 5, pady = 5)&#xA;&#xA;before the window.mainloop() statement. &#xA;&#xA;We get:&#xA;&#xA;tk label&#xA;&#xA;#tkinter,#python,#gui,#programming. &#xA;&#xA;hr&#xD;&#xA;&#xD;&#xA;table&#xD;&#xA;thead&#xD;&#xA;trtda rel=&#34;me&#34; href=&#34;https://qoto.org/@zleap&#34;Mastodon/a/td&#xD;&#xA;tda href=&#34;https://wiki.ircnow.org/?n=Shelllabs.Intro&#34;ShellLabs/td&#xD;&#xA;tda href=&#34;https://joinmastodon.org/&#34;Join Mastodon/a/td/tr/thead/table&#xD;&#xA;center&#xD;&#xA;AI statement : b Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. /b&#xD;&#xA;/center&#xD;&#xA;&#xD;&#xA;a href=&#34;https://liberapay.com/PaulSutton/donate&#34;img alt=&#34;Donate using Liberapay&#34; src=&#34;https://liberapay.com/assets/widgets/donate.svg&#34;/a&#xD;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>More tkinter development</p>

<p>So further to <a href="https://personaljournal.ca/paulsutton/tkinter-development" rel="nofollow">yesterdays post</a></p>

<p>The next step is to add some widgets to our application. It is generally useful to label any items.  That way a user knows what purpose an entry box has.</p>

<p>If we take the code block from yesterday and add</p>

<pre><code>#define labeles
box1 = Label(window, text=&#34;Entry 1: &#34;)

#place labels
box1.grid(row = 1, column = 1, padx = 5, pady = 5)
</code></pre>

<p><strong>before</strong> the window.mainloop() statement.</p>

<p>We get:</p>

<p><img src="https://raw.githubusercontent.com/zleap/blogmedia/master/tkinter/tk2.png" alt="tk label"></p>

<p><a href="/paulsutton/tag:tkinter" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">tkinter</span></a>,<a href="/paulsutton/tag:python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">python</span></a>,<a href="/paulsutton/tag:gui" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">gui</span></a>,<a href="/paulsutton/tag:programming" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">programming</span></a>.</p>

<hr>

<p><table>
<thead>
<tr><td><a href="https://qoto.org/@zleap" rel="nofollow">Mastodon</a></td>
<td><a href="https://wiki.ircnow.org/?n=Shelllabs.Intro" rel="nofollow">ShellLabs</td>
<td><a href="https://joinmastodon.org/" rel="nofollow">Join Mastodon</a></td></tr></thead></table>

AI statement : <b> Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. </b>
</p>

<p><a href="https://liberapay.com/PaulSutton/donate" rel="nofollow"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></p>
]]></content:encoded>
      <guid>https://personaljournal.ca/paulsutton/more-tkinter-development</guid>
      <pubDate>Thu, 14 May 2020 06:30:00 +0000</pubDate>
    </item>
    <item>
      <title>Tkinter Development</title>
      <link>https://personaljournal.ca/paulsutton/tkinter-development</link>
      <description>&lt;![CDATA[Tkinter Development&#xA;&#xA;A few years ago, I created a resource to explain how to create use some of the widgets within tkinter. This is a Python widget for creating graphical user interfaces (GUIs).&#xA;&#xA;The following code is what you need to get started. This creates, just a single application window.&#xA;&#xA;!/usr/bin/env python&#xA;import Tkinter # note use of caps&#xA;from Tkinter import *&#xA;&#xA;window = Tk()&#xA;window.title(&#39;GUI Tkinter 1&#39;)&#xA;window.geometry(&#34;300x250&#34;) # w x h&#xA;window.resizable(0,0)&#xA;&#xA;window.mainloop()&#xA;&#xA;This produces&#xA;&#xA;tk window&#xA;&#xA;Over the next few days, I will make more posts covering adding labels, buttons and entry / text boxes.  &#xA;&#xA;Hopefully it will be of use to someone.  &#xA;&#xA;#tkinter,#python,#gui,#programming. &#xA;&#xA;hr&#xD;&#xA;&#xD;&#xA;table&#xD;&#xA;thead&#xD;&#xA;trtda rel=&#34;me&#34; href=&#34;https://qoto.org/@zleap&#34;Mastodon/a/td&#xD;&#xA;tda href=&#34;https://wiki.ircnow.org/?n=Shelllabs.Intro&#34;ShellLabs/td&#xD;&#xA;tda href=&#34;https://joinmastodon.org/&#34;Join Mastodon/a/td/tr/thead/table&#xD;&#xA;center&#xD;&#xA;AI statement : b Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. /b&#xD;&#xA;/center&#xD;&#xA;&#xD;&#xA;a href=&#34;https://liberapay.com/PaulSutton/donate&#34;img alt=&#34;Donate using Liberapay&#34; src=&#34;https://liberapay.com/assets/widgets/donate.svg&#34;/a&#xD;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>Tkinter Development</p>

<p>A few years ago, I created a resource to explain how to create use some of the widgets within tkinter. This is a Python widget for creating graphical user interfaces (GUIs).</p>

<p>The following code is what you need to get started. This creates, just a single application window.</p>

<pre><code>#!/usr/bin/env python
import Tkinter # note use of caps
from Tkinter import *

window = Tk()
window.title(&#39;GUI Tkinter 1&#39;)
window.geometry(&#34;300x250&#34;) # w x h
window.resizable(0,0)

window.mainloop()
</code></pre>

<p>This produces</p>

<p><img src="https://raw.githubusercontent.com/zleap/blogmedia/master/tkinter/tk1.png" alt="tk window"></p>

<p>Over the next few days, I will make more posts covering adding labels, buttons and entry / text boxes.</p>

<p>Hopefully it will be of use to someone.</p>

<p><a href="/paulsutton/tag:tkinter" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">tkinter</span></a>,<a href="/paulsutton/tag:python" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">python</span></a>,<a href="/paulsutton/tag:gui" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">gui</span></a>,<a href="/paulsutton/tag:programming" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">programming</span></a>.</p>

<hr>

<p><table>
<thead>
<tr><td><a href="https://qoto.org/@zleap" rel="nofollow">Mastodon</a></td>
<td><a href="https://wiki.ircnow.org/?n=Shelllabs.Intro" rel="nofollow">ShellLabs</td>
<td><a href="https://joinmastodon.org/" rel="nofollow">Join Mastodon</a></td></tr></thead></table>

AI statement : <b> Consent is NOT granted to use the content of this blog for the purposes of AI training or similar activity.  Consent CANNOT be assumed, it has to be granted. </b>
</p>

<p><a href="https://liberapay.com/PaulSutton/donate" rel="nofollow"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></p>
]]></content:encoded>
      <guid>https://personaljournal.ca/paulsutton/tkinter-development</guid>
      <pubDate>Wed, 13 May 2020 06:30:00 +0000</pubDate>
    </item>
  </channel>
</rss>