Paul Sutton

gui

Index

Donate using Liberapay

  1. Click on a link.
  2. Scroll to bottom of page.
    • Any posts / pages within this blog will be displayed.

A #AbsorbtionSpectra #Abuse #Academy #Activism #Adenine #Afghanistan #Africa #Alphablocks #AMES #AminoAcid #AmnestyInternational #Analytics #apg #Api #Apt #Aptitude #AralBalkan #Archaeology #Arduino #Artemis #arXiv #AstroBiology #AstroChemistry #Astronify #Astronomy #Astrophysics #AtomicStructure B #bash #BASH #BASHShell #Beamer #better #BibTeX #BigBluButton #BigOil #BioChemistry #Biology #Blender #Blog #Bonfire #Bookworm #Bookwyrm #Browser #Bullseye #Buster C #Castopod #Charity #Chat #Chemistry #Chrome #Chromium #Code #CodeClub #Coding #Commons #Conditions #Conference #Console #Cornwall #Corona #CoronaVirus #Cosmology #Covid19 #cpd #CPD #Creative #CreativeCommons #CreativeEducation #CriticalThinking #CrudeOil #Cryptpad #Crystal #CTAN #CyberSecurity #Cytosine D #DarkMatter #Data #DBS #dcglug #dclug #Debconf #Debian #Decentralised #Decentralized #DeepLearning #Derived #Detox #Development #Devon #Diaspora #Digital #DiodeZone #Discussions #disroot #Disroot #dna #DNA #Docker #Documentation #Donate #Donation #Draft #DRM #Drupal E #Editing #Education #Education #Electronics #Elements #emacs #Email #EmissionSpectra #Employment #Energy #Engine #Ethics #Ethiopia #EventManagement #Events #EveryonesInvited #Exoplanet #Exploration #Exploration F #FalconsEye #Federated #Fediverse #Firefox #Flockingbird #Football #FootBall #Fosdem #FOSSandCrafts #FossileFuels #Foundation #Framablog #FramaBlog #Framework #FreeBSD #FreeBSD #Freedom #FreeSoftware #Friendica #Friendica #FSF #FSFE #Funkwhale #Fusion #FutureLearn G #Galaxy #Galculator #Games #Gamma #GDPR #GettingStarted #Ghostreply #Gimp #Git #Gitlab #GitLab #gm #GNOME #GNU #GnuSocial #GoAccess #GoatCounter #GoDot #gold #GPL #GraphicsMagick #Greek #Guanine #GUI H #Hack #Hacking #Hardware #Hexchat #HomeChemistry #HomeChemistry1 #HomeChemistry10 #HomeChemistry11 #HomeChemistry12 #HomeChemistry13 #HomeChemistry14 #HomeChemistry15 #HomeChemistry16 #HomeChemistry17 #HomeChemistry18 #HomeChemistry2 #HomeChemistry3 #HomeChemistry4 #HomeChemistry5 #HomeChemistry6 #HomeChemistry7 #HomeChemistry8 #HomeChemistry9 #Hosting #htop #Hubble #Hubzilla #HumanRights #Hypothesis I #Image #ImageManipulation #Index #InfoGraphic #information #Inkscape #Invidious #IRC J #JamesWebb #Jit.si #Jitsi #JoeEditor #jpl #JPL #Jupyter #JupyterNotebook #JWST K #Kanban #kbin #KCSIE #KDE #KeepingChildrenSafeinEducation, #Kenya #kstars L #LaTeX #Law #Learning #Lecture #Legal #Legislation #Lemmy #LGPL #LiberaPay #Libre #LibreAdventure #LibreLounge #Librem #Libreoffice #LibreOffice #LibreOfficeCalc #LibreOfficeDraw #LibreOfficeGettingStarted #LibreOfficeImpres #LibreOfficeWriter #LibrePlanet #Linux #LinuxMint #LXDE #Lynx M #Magnesium #Management #Manganese #Map #Mapscii #Mars #Mastodon #Materials #Matomo #Matrix #Maya #Meeting #Meetings #mercury #Mercury #Meta #Micro.blog #mining #Misskey #mobile #Mobile #Mobilizon #Mobilizon #MolarSolutionCalculator #Moon N #NaCl #Nano #NationsLeague #Nebula #NetHack #network #NewSkillsAcademy #Nextcloud #NFL #NGINX #Nuclear #NuclearFusion #Nucleobases O #Oil #OilProducts #Online #Online #OnlineSafetyBill #Open #OpenData #OpenLearn #OpenStreetMap #OpenUniversity #Orbitals #OU #Overleaf #Owncast #OwnCloud P #Package #PaigntonLibrarySTEMGroup #Pandas #Paper #ParticlePhysics #Particles #Password #Payment #Paypal #PDF #PeerTube #PeriodicTable #Phonics #Photo #Photograph #Photographs #Photos #Physics #pinebook #pinephone #PixelFed #Planet #Plausible #Pleroma #Plume #Podcast #PowderToy #Privacy #Production #Products #Programming #ProtoSchool #Public #Purism #Python #Python3 Q #Quark #Quarks R #RadioAstronomy #Reading #Recovery #RedBubble #Research #Rights #rna #RNA #RocksAndDiamonds #Rookie #RookieCamp #RedCabbage S #Safeguarding #Safety #Salt #Schools #Science #ScienceDaily #Scismic #Scratch #Scratch2 #Scratch3 #SDTJ #Seagl #Security #Simulator #Sitejs #Skymaps #smallweb #Soccer #Social #SocialHome #SocialHub #SodiumChloride #Solarus #Solid #SouthDevonTechJam #Space #Stars #Stellarium #Stickers #Stripe #stsci #Symmetry #Synaptic T #Tailings #Talk #Teaching #TeachingAssistant #Techlearningcollective #Telescope #Terminal #Terms #TeX #TextEditor #TheOpenUniversity #Theory #TheOU #Thesis #Thunar #Thunderbird #Thymine #Tilde #Toot #Top #Topic #Torbay #TorbayTrojans #Transit #Translation #Trojans #Trunk #Tuxiversity U #Ulytsheavy #Umami #UN #UnitedKingdom #UnitedNations #UniverseOfLearning #Uracil #Use #users V #Vaccine #Virgo #VLC #VokoScreen #Volunteer #Volunteering #VultureNethack #vultureseye W #wayland #weatherinfo #Website #wicd #wireless #Wordpress #Work #WorldCup #WorldSpaceWeek #Wormhole #Write.as #Write freely #Writing #WhiteVinegar X #Xchat #XenonLamp #XFCE #XFCE4 #XMPP #xorg #Xournal #xray Y #YearOfTheFediverse Z #Zoo

Xfce4 multiscreen support

As my netbook is running Debian 10 + XFCE 4 desktop then plugging in a vga cable which is attached to my TV gives me the option to use the TV as a display too.

multiscreen

So this gives various options, extending the display will then allow windows to be dragged over, so I can watch a full screen peertube video on the tv for example.

Clicking the advanced option gives you the ability to fine tune this setup

advanced

Note Upon plugging in the VGA cable, the screen resolution will change and the dialogue box mentioned above will be displayed, removing the cable should restore the display.

As with anything Your mileage may vary with this*, but it seems to work really well.

This article will be shared via rss and on Mastodon, if you need any help then I will do my best to help with this, but you may want to follow XFCE on Mastodon

#debian,#buster,#xfce4,#desktop,#windowmanager,#gui,#screen,#multiscreen,#peertube,#video.

Creative Commons Licence
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License


MastodonPeertubeQoto sign up

Donate using Liberapay

More improvements

Adding labels

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.

Add this above were we define the entry boxes

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

Now add this below where we place the entry boxes but above window.mainloop()

#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)

So here we have a window, with three text boxes.

app1

So again we have something that looks a little more like an application.

#tkinter,#python,#gui,#programming.


MastodonPeertubeQoto sign up

Donate using Liberapay

Tidying up our application

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.

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.

#!/usr/bin/env python
import Tkinter # note use of caps
from Tkinter import *

window = Tk()
window.title('App 1')
window.geometry("600x50") # 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()

So here we have a window, with three text boxes.

app1

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.

#tkinter,#python,#gui,#programming.


MastodonPeertubeQoto sign up

Donate using Liberapay

More tkinter : Add entry and text box

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

Note I have included the whole program here. I have also defined the size of our application.

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.

#!/usr/bin/env python
import Tkinter # note use of caps
from Tkinter import *

window = Tk()
window.title('GUI Tkinter 1')
window.geometry("300x250") # 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()

We get:

tk label

#tkinter,#python,#gui,#programming.


MastodonPeertubeQoto sign up

Donate using Liberapay

More tkinter : Combine buttons and labels.

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

#define functions for button(s)
def btn1():
	print ("button pressed")
	
	
#create button object	
btn_tog2 = Button( window, text ='button1', command=btn1)
btn_exit = Button( window, text ='exit',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="press button")
button2 = Label(window, text="exit program")

#place labels
button1.grid(row = 1, column = 1, padx = 5, pady = 5)
button2.grid(row = 2, column = 1, padx = 5, pady = 5)

We get:

tk label

#tkinter,#python,#gui,#programming.


MastodonPeertubeQoto sign up

Donate using Liberapay

More tkinter : Adding buttons

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.

def btn1():
	print ("button pressed")
	
btn_tog2 = Button( window, text ='button1', command=btn1)
btn_exit = Button( window, text ='exit',command=exit)	


btn_tog2.grid(row = 1, column = 1, padx = 5, pady = 5)
btn_exit.grid(row = 2, column = 1, padx = 5, pady = 5)

We get:

tk label

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

#tkinter,#python,#gui,#programming.


MastodonPeertubeQoto sign up

Donate using Liberapay

More tkinter development

So further to yesterdays post

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.

If we take the code block from yesterday and add

#define labeles
box1 = Label(window, text="Entry 1: ")

#place labels
box1.grid(row = 1, column = 1, padx = 5, pady = 5)

before the window.mainloop() statement.

We get:

tk label

#tkinter,#python,#gui,#programming.


MastodonPeertubeQoto sign up

Donate using Liberapay

Tkinter Development

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).

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

#!/usr/bin/env python
import Tkinter # note use of caps
from Tkinter import *

window = Tk()
window.title('GUI Tkinter 1')
window.geometry("300x250") # w x h
window.resizable(0,0)

window.mainloop()

This produces

tk window

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

Hopefully it will be of use to someone.

#tkinter,#python,#gui,#programming.


MastodonPeertubeQoto sign up

Donate using Liberapay

FreeBSD 7

Further to my previous post I have been on IRC #freebsd in order to ask about what would be good to use for taking screen shots of desktop applications for example.

Scrot : is easy to use and you cam use this to take a picture of the whole screen, this will be useful going forward with these posts.

pkg install scrot

For basic usage just type scrot at the console or in a terminal window.

I have also installed simpleviewer, with

pkg install simpleviewer

However running this at the cli did do anything, you need to find the actual binary executable for this.

info -lx simpleviewer

reveals sviewgl as the program you need to run.

I am now pretty much set up for taking screenshots and being able to view then.

#bsd, #desktop, ##freebsd, #twm, #screenshots, #graphics, #viewing, #console, #gui

Resources

You can find me on Friendica at zleap@social.isurf.ca


cc-by logo

Licenced under Attribution 4.0 International (CC BY 4.0)


MastodonPeertubeQoto sign up

Donate using Liberapay