Create Resizable and Moveable Object on the Desktrop Screen in Python - python

Hey Guys. Hope you are all doing well.
Right now, I need to create a moveable and resizeable circle object with Python. I need to be able to resize the object by dragging my mouse over its corners (just like I would do on Paint), and move it by dragging my mouse on it. And I do not want this circle object to appear on an external app screen/window. Let me show you what I mean by that:
Above image is what I want. This circle needs to be moveable and resizeable.
I though about using Tkinter, however, I do not have many knowledge on it. I do not know if I would be able to remove the Tkinter app screen, and make the object moveable. Can you help me with that?

Related

How to draw a square outside of the application window in python tkinter

Question: Is it possible to use python to draw a box anywhere on the screen, outside of the application window.
Background:
I have some mouse/keyboard macros I use for work, programmed in python pyautogui, and have to make new ones and adjust them frequently. I would like my program to be such that I can use my mouse to draw a box over any part of my screen over any application window, and record the coordinates of the box for use within my macros. The box would be used as the selector, and would disappear once recorded. Basically the same thing as when you hold down your left mouse button on your desktop to select multiple icons, except I would just need the coordinates of the box to be returned for use in the macros (which I can already do with pyautogui).
Is it possible to draw outside of the canvas window? Perhaps there is a way to hide the canvas window without hiding the contents within it?

I want to add a scrollbar to the screen of my app but I'm using grid instead of pack and I don't want to use a canvas. I'm a beginner by the way

Iv'e tried a bunch of random things. I know I'm supposed to be specific when explaining this but I don't really know what to say. I made a scrollbar in a def function, it was in a whole new screen and I added it to a text box. So I'm wondering if I can just add my main scrollbar to the frame/screen in my main window. My previous scrollbar is in the recipe_steps function.

Is there a way to take a "screenshot" in pygame, and then save it as a sprite so as to reduce code complexity?

The title says it all, although in my instance, the reason I wish to use this feature is I plan on having a all this stuff moving around, until I call this "dialogue()" function, when everything will stop, and I will have dialogue options moving about the screen. However, I don't want to continually render everything in the background, so is there some way of going about taking a screenshot in pygame?
You can capture the contents of the Pygame.Surface by making a copy with screen.copy() then when you want to redraw you use screen.blit(copy, (0,0)). And then you draw on top of that.
Another option is to change your code so that you render the background into a separate surface rather than copying it from the screen and then combine the foreground with the dialogue with it by bliting the background and then the foreground to the screen.
If this isn't right for you, please share more about your program. I haven't used Pygame in a while so this is mostly based on the documentation https://www.pygame.org/docs/ref/surface.html

Pygame help needed

I am new to PyGame and need some help!
Let me start of by saying that I have a basic understanding of the Python language, I recently started learning how to use PyGame as well as it was something new to me. However I do get stuck quite a lot when trying to code for PyGame. Just so that you know I have read and watched a lot of tutorials but none of them helps me in the way I need it to.
My problem is that I am trying to get a box to appear on the screen that has a word written on it, such as: "Hello". Once that button is clicked then hello should appear.
Here is my plan:
I make a class named pane
Properties of that class would be things like: xpos, ypos, text, width height
Methods of that class would be things like: add(textToDisplay), delete(textToDisplay) - (The delete function is currently not all that important), displayPane()
If possible could you please tell me if this is actually doable using python and pygame/sort of hint to me how I would do it (Like with some useful links because Google has not been my friend for when it has come down to the searching. XD )? and if it isn't what language would you recommend I do it in?
Take a look at:
http://pygame.org/docs/ref/mouse.html#pygame.mouse.get_pos
http://pygame.org/docs/ref/rect.html#pygame.Rect.collidepoint
http://pygame.org/docs/ref/draw.html#pygame.draw.rect
http://pygame.org/docs/ref/font.html#pygame.font.SysFont
My suggestion is a procedural approach if you're dealing with only one shape:
Use pygame.draw.rect to draw a rectangle on a point.
Use a function to capture mouse clicks and their positions.
Collide mouse clicks
with you rectangle position (use a list of objects if you have
several).
Create a function to draw text on the screen and associate
it with the function which collides mouse clicks to rectangles.
Otherwise I'd take an object-oriented approach and use the pygame.sprite.Sprite class for each shape, or custom classes if you have special needs. The click capture-and-colide part would still be procedural, of course.
I adapted a project I'm working on to do what I think is what you want:
You can't actually see the cursor but I'm clicking with the middle mouse button to create the circles and with the main button to display the text.
Source: http://pastebin.com/jycEFAtX
Note: It's a circle and not a rectangle because I was working with circles, but that should be easy for you to change. Everything is a mess because I just adapted what I had and put it all together on a single file (it's probably better to separate it into different files). Use it just to get an idea of how to do what you want.
You can delete the text by setting obj.text as None, for example when event.button == SECONDARY_BUTTON, that way you can delete the text by clicking with the secondary mouse button on the circles.
P.S.: Notice I have a function that collides objects with mouse position (because it's needed for what I'm working with), but you don't need that. You can use pygame.Rect and pygame.Rect.collidepoint, as suggested above.

How to set the screen resolution in pythoncard

I want to set the resolution of my application as per the resolution of the system screen its running on. i want to be on top and also in full screen covering even the taskbar as i am using windows. i want the app to open like the ATM interface, so the app should fill the entire screen.
please help me to find the solution.
thanks
The frame object has a "ShowFullScreen" method that you could use. I just tested it and it works alright, although it doesn't show the title bar of the app. I don't know if you care about that though.
EDIT: Uh, to call a method on the frame object, you would do something like
self.ShowFullScreen(True)
or
myFrame.ShowFullScreen(True)

Categories

Resources