I'm using python3 with Tkinter but I can't get over that i need a mainloop() statemment to get the screen to pop up and draw, then only by closing the graphics screen will the program then go on to the text to speak section. How can I have my graphics displayed without the program halting?
Related
Here is my problem. I developed a tkinter GUI for my project. However I am stuck with tkinter limitations. I developed python gui to create a virtual view for a red table as below. The window does not have any border or title. It is just put on the a picture background which is outside of the code.
However as you can see it is not lively enough for me. I want it to look like this:
Is there a way to do this in tkinter? I tried transparent backgrounds, however in Ubuntu transparent background with visible object is not possible. Also You cannot make different window shapes other than rectangle. What is your suggestions? Should I use another library. I really need an expert opinion about this.
Transparent background reference
Different window shape other than rectangle
My environment : Ubuntu 16.04 Python 3.5.2
You can't specifically change the shape of a Tkinter Window, but you can create a canvas and design your own shape (then add your buttons and labels on this canvas if needed).
You can also take a look at PyQt or Kivy, but if you are confortable with Tkinter go with Canvas.
So to solve my issue I found a python library wxPython:
You can check this link it creates Wx non rectangular shape
It creates the the window using inheritence. I tried selected answer and It solved my question.
Btw I tried QTPython, Kivy, tkinter. Non of them had straight example such wxPython.
the problem = I dont know how to get a program to detect a input from the keyboard without using IDLE
A solution to my problem would look like; some code so that when a key is pressed it sets/makes a variable.
(I am doing this on a raspberry pi)
eg. code code code 'user presses space bar' pi camera takes picture and ends the preview. I dont want it so that the input is in the python shell, just when the space bar is pressed. just to note I am a beginner coder who knows next to nothing so if you can help or point me in the right direction I would be grateful.
edit:
here is the code I have so far
from picamera import PiCamera
from time import sleep
import webbrowser
#importing all the needed things
webbrowser.open('/home/pi/RyansScienceFair/test.html')
#opens a webbrowser that I coded
camera = PiCamera
camera.start_preview(alpha = 220)
sleep(10)
camera.stop_preview()
#runs the camera for 10 seconds with some transparency
what I want is when the user is looking at the web page, which will be displayed under the camera display, they can press spacebar and then the program takes a photo and then ends the camera preview. I can do the camera capture and work out the end time for the camera but its the trigger that I cant figure out.
I am currently stepping through the tkinter tutorial at python-course.eu. Is it possible to close an entry widget without killing the program? What I am trying to do is incorporate the tkinter entry box into a pygame program such that the program asks for the players name via an entry box and then closes once the text has been entered. The game should then continue. Is this possible?
What I would like to do is:
-create a pygame surface
-open a tkinter entry widget on top of that surface
-get the users name
-close the tkinter widget
-write text using pygame onto the surface that incorporates the user's name
What is stumping me is the fact that the tkinter examples on python-course.eu all end with a mainloop() statement while I would like pygame to have an event loop so that I can expand the program. I anticipate that the widget creation would occur prior to dropping into the event loop. This is where I am stuck :-(
rather than trying to mix two GUI libraries in the same window, if a prompt is acceptable you could use:
import tkinter as tk
from tkinter import simpledialog
root = tk.Tk() # needed to prevent extra window being created by dialog
root.withdraw() # hide window as not needed
username = simpledialog.askstring('Username', 'Enter username:')
root.destroy()
I'm trying to embed xterm in a PyQt application window for tailing a log file. However, I want to block keyboard input from the user in the embedded terminal, so that they don't, for example, press CTRL-C or CTRL-D, and kill the process.
I'm able to embed the terminal just fine. Is there a setting for xterm or PyQt that can be used to block user input? I want this to be a read-only terminal, that just displays the content of the log file.
I've searched the manpage for xterm, and haven't found anything.
The way to approach this would be to construct a transparent (actually "uncolored") window which overlays the embedded xterm window.
There is an example described in Basic X Window keyboard and mouse input blocking which is essentially a screensaver written in Python. For lower-level (X documentation) on window properties, the links in How to prevent an X Window from receiving user input? may be useful to you.
The main problems to solve would be (in your program) how to ensure that the overlaid window comes on top, and of course how to keep it transparent (since that diverges from the example). The latter is more complicated:
Transparent window in Xwindow parent
Empty or transparent window with Xlib showing border lines only
I would like to get the image of an X server Window (toplevel window, parent is the root Window) with its border/frame/title bar. I have already tried several libraries (Xlib, XRender, gdk, cairo) but none of them works. The captured image has the same geometry as the window but the frame is missing.
The problem is that the child window which should hold the frame image is InputOnly. The reason might be for this that the frame is rendered by the window decorator on the fly the same time as the Window itself.
I cannot capture the image from the RootWindow as the Window might be partially or entirely covered.
Redecorating the captured Window image could be an alternative.
Any suggestions? Thanks.
PS. When compiz is not running everything works as expected.
I use shutter for screen shots on linux, it's super easy to capture whatever portion of the screen you want. As a bonus, there are tools to add arrows or highlight sections.
http://shutter-project.org/preview/screenshots/