I'm making a blackjack game using Python, and the GUI with Tkinter.
I have this so far. It doesn't output the cards yet.
Without cards
I have then used this bit of code to try and link the photos to the file:
code, and this is the output:
with cards.
This is where the problems start.
it is really inconsistent. I have to try to open the file several times in order for the game window to actually open.
When it does finally open, it doesn't work properly. When I click the 'hit' button, I can see that the number of cards left in the deck is going down ( top left corner of the screenshots ), but the photos don't change ; they just remain as the ones in the screenshot.
If I spam click the shuffle button, one of them might change to another image, but they mostly remain the same.
If I remove those lines of code linking the images, it works properly and as expected ( first screenshot ). The cards actually change when 'hit' and 'shuffle' are clicked, although its just the name of the card and not the image.
I'm very new to Tkinter, and this is my first program using it. Can someone please suggest any changes/improvements I can make so that the images of the cards change everytime 'hit' and 'shuffle' are clicked, and also explain briefly why its that way? Any and all help will be greatly appreciated.
Thanks a lot
I am developing a cross platform app in Python using wxPython. The app is fully developed, and the graphics toolkit is set in stone, at least for the time being.
On Windows, everything looks great. On Linux, everything looks pretty good. On Mac, I am having trouble with a combobox/choice being hidden in the toolbar, even though it shows up fine on Windows.
Here is a snapshot of my app on Linux, noting the entire "CoeffConv ..." section is part of the perfectly displayed combobox:
And here is a snapshot of the same exact codebase on Mac:
I've tried with wx.ComboBox and wx.Choice with the same effect. I've made sure to call Realize() after I've added my toolbar items. I've made sure AddControl is called to actually add the object to the toolbar. It's definitely trying to render because the spacing is exactly what I would expect, given the contents of the choice field.
In fact, if I don't call AddControl, but I create the choice field with the toolbar as the parent, the box gets rendered but things aren't arranged properly due to the missing AddControl call:
As another check, I created a super simple toolbar with choice demo, and it works just fine:
So, here's the summary of things I know:
On Windows, the choice field works perfect, indicating the code isn't necessarily wrong.
On Linux, the choice field works perfect, supporting the idea that the code is actually OK.
On Mac, the choice field is present it seems, but somehow invisible, implying this is a problem with the Mac, or the Python distribution on Mac, or the combobox control in the wxPython distribution on Mac.
On Mac, I can get the choice to render (improperly but still) without an AddControl call, indicating the combobox can render properly, but something is goofy about the placement when added to the toolbar
However, On Mac, I can get a toolbar/choice to render totally fine in a dummy example, indicating it's something about my implementation...but I can't figure out what would cause it as I'm trying to make the exact same calls to the wx objects as in the dummy example.
I can't get the dummy example to reproduce the problem, but I'll keep trying. I'm happy to report out some object properties if they would be helpful in diagnosing. If someone has a clue for what could cause it to not show up, I'd really appreciate it!
While I couldn't find the root as to why it didn't work on Mac, I did find an issue that could help others.
First a little more background. In the app, we have multiple toolbars. Because of that, we are creating toolbars using plain wx.ToolBar objects and adding them to the app frame using sizers. This is in contrast to the more standard method of using self.CreateToolBar() which only allows a frame to have a single toolbar.
When I make a single change to the code to use the more natural CreateToolBar interface, the combobox immediately shows up. When I do that, the second toolbar is messed up, but at least the initial toolbar works perfectly. I'll be investigating how to get multiple toolbars on Mac, but it's a step in the right direction.
It's been a while, but there's another solution to this for wxPython 4 if you can't use CreateToolBar():
The widgets do get added to the bar and reserve the correct amount of space, but they fail to draw properly. You can resolve this by calling control.Hide() followed by control.Show() on each widget control, which then makes them draw properly.
Hello I need help making my buttons and labels to stay fixed whenever I'm changing the display resolution. I have a video link of what I mean by that.
link: https://youtu.be/GJ3f88ebDqc?t=29s
If anyone could make me a example of code or explain and show me that would be great. Thanks!
Read kivy documentation about size_hint and pos_hint in the layouts you are using, and read the documentation about layouts in general.
https://kivy.org/docs/gettingstarted/layouts.html
https://kivy.org/docs/api-kivy.uix.layout.html
if you are still blocked, post a short code showing what you have in a simple way, and explain what's not behaving how you expect it to.
I've been looking for a way to screenshot a window that is not on top. It's not minimized, just covered by another one which is active.
For instance, let's say I want to screenshot an online chat (window 1, not active, running in the background, not minimized) while watching a youtube video (window 2, active, showing on screen).
I'm pretty sure there are ways to do this, most of flash application keep rendering even when covered by another window.
Currently, I havn't found anything reliable.
I have been looking at C++ solutions and python ones (but I'd rather have a python one). A VBA one would be great too since I often work with macros.
I also though of creating a virtual dual screen, and assigning the window I want to screenshot to it, to have it rendering the window. But I don't know how and if it could work.
If you have any ideas, let me know :)
Thank you
Well i am creating a utility for my own needs, that being to help improve my reading on the computer. What i need to do is create a tool which can add a colour filter to a section of the screen, as well as add zoom. The first thing was easy to do, i set the attributes to add alpha, topmost and gave a frame a set bg colour.
What i dont know how to do is the zoom. I was thinking of getting a screen capture cut the selected bit apply image transformation then render it in the window. Of course the utility window will also be drawn and obscure the screen capture. I dont know tkinter well enough and i really want to avoid doing GDI work, but if someone has a solution with it i dont mind using it. Clearly referencing GDI, im making it to run on windows.
Optional: Something i have a work around for but would be nice to have is the ability to click through a window, but i doubt i can do that with tkinter.
EDIT: Since im getting negative votes, and i don't know why please help me improve with a comment.
I'm not looking for someone to do the work for me i just want a hint on what might be the right way to do this. With the main problem being how to get a image for whats underneath the Tkinter window so i can process it.