Go to advanced search

by RogerW
Mon Mar 06, 2017 10:02 am
Forum: Python
Topic: Display a Meter
Replies: 11
Views: 1689

Re: Display a Meter

Glad to help. The first file (meter.py) contains the meter class. The second file (trymeter.py) is just a testbed. You can write your own tkinter program to include a meter object and drive it any way you like. It should not be too difficult to modify the meter class to have the needle start horizon...
by RogerW
Sun Mar 05, 2017 9:42 am
Forum: Python
Topic: Display a Meter
Replies: 11
Views: 1689

Re: Display a Meter

There is some code in this link which might help.

viewtopic.php?f=38&t=134854#p897766
by RogerW
Sun Feb 26, 2017 5:25 pm
Forum: Python
Topic: Trouble updating tkinter label with variable
Replies: 7
Views: 5512

Re: Trouble updating tkinter label with variable

You could try something allong these lines. import tkinter as tk class Mainframe(tk.Frame): # Mainframe contains the widgets # More advanced programs may have multiple frames # or possibly a grid of subframes def __init__(self,master,*args,**kwargs): # *args packs positional arguments into tuple arg...
by RogerW
Sun Feb 19, 2017 1:45 pm
Forum: Python
Topic: How to stop a running script in tkinter
Replies: 8
Views: 4996

Re: How to stop a running script in tkinter

Threads are very powerful but do need car. Tkinter widgets have a function "after" which alows a function to be called after a given delay. It is not precise but can ofter be adequate. This might offer a simpler solution. import tkinter as tk class Mainframe(tk.Frame): # Mainframe contains the widge...
by RogerW
Sun Oct 02, 2016 9:35 pm
Forum: Python
Topic: Python Creating Guage
Replies: 6
Views: 1059

Re: Python Creating Guage

Yes thats the one I meant. Not sure why my link whent wrong.
by RogerW
Sun Oct 02, 2016 4:36 pm
Forum: Python
Topic: Python Creating Guage
Replies: 6
Views: 1059

Re: Python Creating Guage

Have a look at this link
viewtopic.php?f=38&t=134854&p=8977

You could use or adapt the meter classes to do what you need.

You need to put the two files (meter.py and trymeter.py) in the same directory and then run trymeter.
by RogerW
Fri Sep 16, 2016 8:31 am
Forum: Graphics programming
Topic: tkinter panedWindow
Replies: 1
Views: 1790

Re: tkinter panedWindow

PanedWindow does not seem to be very well documented. I have not been able to find much on its correct use. This slightly more elaborate version of my previous post might help. import tkinter as tk # create main window main = tk.Tk() main.title("Panes") # create a paned window and place it on the ma...
by RogerW
Thu Sep 15, 2016 1:35 pm
Forum: Graphics programming
Topic: tkinter panedWindow
Replies: 1
Views: 1790

Re: tkinter panedWindow

I think part of the problem is that you do not need to pack the widgets in the paned window - you have to add them. import tkinter as tk root = tk.Tk() root.title("Panes") root.geometry("200x100") panes = tk.PanedWindow(root,orient = "horizontal",showhandle = True) panes.pack() left = tk.Label(root,...
by RogerW
Sat Jun 18, 2016 10:44 am
Forum: Python
Topic: Open another window and switch between?
Replies: 20
Views: 3098

Re: Open another window and switch between?

I have used Tkinter to show graphs and also provide different screens. I do this by overlapping Frames and only showing one at a time. The application is to show system information but you may be able to use similar techniques for your program. The code is on GitHub https://github.com/RogerWoollett/...
by RogerW
Tue May 03, 2016 9:54 am
Forum: Python
Topic: Tkinter GUI Magic 8 Ball Program (CODE included)
Replies: 2
Views: 1660

Re: Tkinter GUI Magic 8 Ball Program (CODE included)

I am not sure how to best put in your graphic - I suggest you look at Canvas widgets. Clearing the question and answer fileds is easy. Add a "Clear" button and in its command function put null strings into the StringVar objects associated with the widgets. This is my solution. I user python3 so you ...
by RogerW
Tue May 03, 2016 8:06 am
Forum: Python
Topic: Tkinter GUI Magic 8 Ball Program (CODE included)
Replies: 2
Views: 1660

Re: Tkinter GUI Magic 8 Ball Program (CODE included)

Two small points:

Code: Select all

import Tkinter
from Tkinter import *
The first line is redundant.

Code: Select all

        if y == True or 1 == 0:
You have a "one" not an "el"

I will try to look at your main point later today.
by RogerW
Wed Apr 20, 2016 3:25 pm
Forum: Python
Topic: Making button and text widgets using tkinter
Replies: 6
Views: 1157

Re: Making button and text widgets using tkinter

Where are you going to get the text from? You say two buttons but it looks more like you need one button and a textbox.
by RogerW
Sat Mar 26, 2016 6:19 pm
Forum: Python
Topic: Getting started with GUI Creation + Online APIS
Replies: 3
Views: 777

Re: Getting started with GUI Creation + Online APIS

You will find lots of different styles for creating a GUI using tkinter. Here is another. import tkinter as tk class WorldFrame(tk.Frame): # frame window def __init__(self,*args,**kwargs): tk.Frame.__init__(self,*args,**kwargs) label = tk.Label(self,text="Hello world") label.grid(column = 0,row = 0)...
by RogerW
Fri Mar 18, 2016 9:31 am
Forum: Beginners
Topic: Running GUI based C++ app on raspberry pi
Replies: 1
Views: 573

Re: Running GUI based C++ app on raspberry pi

I am new at raspberry pi. I have this GUI based C++ application created using visual studio. I want to run that application on raspberry pi. How can I do it ? Thank you ! It depends what GUI framework you used. If you used MFC then I suspect you will have to start again. If you used a framework sup...
by RogerW
Wed Mar 16, 2016 3:37 pm
Forum: Python
Topic: test script: using python-tkinter
Replies: 6
Views: 1171

Re: test script: using python-tkinter

Welcome to the womderful world of tkinter. Tkinter requires some study, The best documentation I know is http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html I agree this is the best but it is not complete so sometims you need to resort to Google And here is a simple application example http...
by RogerW
Mon Mar 14, 2016 5:23 pm
Forum: Python
Topic: global name b2 is un defined
Replies: 4
Views: 805

Re: global name b2 is un defined

You need to understand the concept of scope. b2 is defined in checkpg1 but is not visible outside that function. b1 is defined as a global near the end of the program but also as a local variable in checkpg2. def foo(): #global x x = 9 x = 3 print(x) foo() print(x) Run this little program and it wil...
by RogerW
Thu Mar 10, 2016 3:05 pm
Forum: Troubleshooting
Topic: Starter question rpi.gpio
Replies: 4
Views: 529

Re: Starter question rpi.gpio

Its not clear to me how this works at all. Yo seem to turn the LEDs on every time round the loop but not turn them off. Also there seems to be no way for the loop to exit. One thing you should do is not create PWM objects each time round the loop. Lines like: RED = GPIO.PWM(red, 100) should be befor...
by RogerW
Tue Mar 01, 2016 2:27 pm
Forum: Python
Topic: Using tuple/lists and functions
Replies: 6
Views: 908

Re: Using tuple/lists and functions

Would this do (data 1-3)

Code: Select all

def fna():
    print('a')
    
def fnb():
    print('b')
    
def fnc():
    print('c')

fns = [fna,fnb,fnc]
data = [1,3,2,2,1]

for i in data:
    fns[i-1]()
by RogerW
Mon Feb 29, 2016 3:53 pm
Forum: Beginners
Topic: Greater than signs not working
Replies: 10
Views: 966

Re: Greater than signs not working

Import digitalfaceio as p
Only needs to appear once so put it at the beginning of your file
p.init ()
probably only needs to execute once so again I would put that at the beginning of your program
P.digital.write (x,y)
is doing the work so leave it where it is
by RogerW
Mon Feb 29, 2016 3:13 pm
Forum: Beginners
Topic: Greater than signs not working
Replies: 10
Views: 966

Re: Greater than signs not working

I think
if read_temp_1 <= 22:
should be
if read_temp_1() <= 22:

read_temp_1 is a function and should be called.

Incidentally it is inefficient to put the imports in the loop. Convention is to put them at the top of the file. That may go for
p.init() as well.
by RogerW
Mon Feb 29, 2016 12:00 pm
Forum: Graphics programming
Topic: Tkinter root.after help
Replies: 15
Views: 8722

Re: Tkinter root.after help

Not strictly true! I disagree - root and master are not keywords. It is true that master is an attribute of the widget classes used to store the parent parameter passed to the constructor but that does not make it a keyword. I was trying to keep things simple for the OP and explain the ownership hi...
by RogerW
Mon Feb 29, 2016 9:42 am
Forum: Python
Topic: function call as a parameter default only gets called once
Replies: 4
Views: 631

Re: function call as a parameter default only gets called on

Yes (to my surprise) it is documented. This is from the 3.4.3 documentation. Default parameter values are evaluated from left to right when the function definition is executed. This means that the expression is evaluated once, when the function is defined, and that the same “pre-computed” value is u...
by RogerW
Mon Feb 29, 2016 9:35 am
Forum: Graphics programming
Topic: Tkinter root.after help
Replies: 15
Views: 8722

Re: Tkinter root.after help

Master is only used when you use a frame? Esentially yes. Remember root and master are only names that you write. They are not keywords. All window objects except the root window (owned by the Tk object) need to know their parent. That is why when you create a frame or indeed any other widget the f...
by RogerW
Sun Feb 28, 2016 6:01 pm
Forum: Python
Topic: How to call another import on this module
Replies: 3
Views: 869

Re: How to call another import on this module

But i don't know how to add parameter or not on connection_server module.
Again - not sure I understand what you want. import is executable so you can do:

Code: Select all

if condition:
    from x import import X
by RogerW
Sun Feb 28, 2016 5:40 pm
Forum: Python
Topic: How to call another import on this module
Replies: 3
Views: 869

Re: How to call another import on this module

Unless I have missed something that should work. The two files should be in the same directory.

Go to advanced search