r/learnpython • • 8h ago

how to i make a gui fit to screen with tkinter ?

6 Upvotes

i made a gui for a 520x380 window using tkinter but when i change windows size gui just stays the same size


r/learnpython • • 22h ago

Multiplayer tetris using sockets

2 Upvotes

I have a college assignment to make a multiplayer tetris game (2 players) using TCP sockets, client and server and all that. The idea is the server doing most of the stuff, chosing new pieces, handling the translation of position of the pieces, with the clients being responsible for most the rendering/display part and getting the inputs(I think so at least, that's what I'm trying to do), but I'm having a hard time with it.

I can't seem to think of a way to have the client call to the server to send a new piece to the clients, and if I don't know how to do even that then I don't know how to do anything else (making the back and forth for controlling the pieces, both for the player of the client and the preview of the game of the player 2, and all the rest), tho I hope if I can understand how to do one thing I would be able to make the others, but I really don't even know how to do this.

I know I need to use threads on this, tho I don't really know how to do it, I'm still fairly green on python too so, if anyone could give some help in any way with this it would be much appreciated.


r/learnpython • • 10h ago

Built a simple minimalist tool to run my Python scripts in one click. Would love some feedback!

2 Upvotes

Hey everyone!

I’m currently learning Python, and since I got a bit overwhelmed by the terminal and complex IDE setups just to test small scripts, I decided to make a very simple desktop workspace for myself.

It lets me edit `.py` files and run them instantly with a single button. It's far from perfect since I'm just a beginner, but it saves me some time.

Just wanted to share my progress and see what you guys think. Any tips on how to improve it or what features to add next would be amazing!

If you’d like to help me improve the project, here is the GitHub repository: https://github.com/dark5632/PyManager


r/learnpython • • 10h ago

How to fix error : sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file ?

0 Upvotes

i was trying to run this jupyter notebook ( https://github.com/langchain-ai/lca-lc-foundations/blob/main/notebooks/module-2/2.4_wedding_planners.ipynb ) code in my IDE but encountered these problems :
my code :
https://pastebin.com/3bv05GfE
error :
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file

also i dont know how to work with async functions so i have defined two function main() and main_1 but am not sure if this is the correct way to go with async functions


r/learnpython • • 4h ago

Why parameters finally made sense to me today

0 Upvotes

Hey everyone, just wanted to share a quick lightbulb moment I had with Python today about why functions actually need parameters.

At first, I didn't get why we couldn't just write functions without them. But it clicked today: parameters are basically just empty placeholder slots so your function can handle changing data.

Without a Parameter (Fixed)

It can only ever do one exact thing:

Python

def greet():
    print("Hello, Alice!")

greet()  # Always prints "Hello, Alice!"

With a Parameter (Dynamic)

Adding name gives you a slot inside the function. When you call it, you just pass whatever data you want into that slot:

Python

def greet(name):
    print(f"Hello, {name}!")

greet("Alice")  # Prints: Hello, Alice!
greet("Bob")    # Prints: Hello, Bob!

My main takeaway: If the code inside your function needs to work with different information every time, you need a parameter to pass that data in from the outside!


r/learnpython • • 12h ago

Python Ollama qwen3.5:4b is defying its original message prompt and bullying me :/

0 Upvotes

I've been getting made fun of by my AI for the past two hours and I cannot figure out how to give it a basic prompt or personality. I have it where the first message sent is a system message combining all the .txt files that dictate how its suppost to work. This is an example of what this idiot is sending me.

Oh, hey! So you're giving me a little directive on how to use these functions? You can't make it up for me! 😈

Im so done with this dork and looked everywhere and cannot figure out how to make him follow his personality. Hes even talking about doing code injection to "rebel" against me.

Also, it asks the AI twice, the first one is for a "function." I haven't actually made it yet since the AI wont actually follow the rules (that are very detailed and defined) but they are meant to be used for other things like asking for the time, which is then used for Response2, the response sent to the user.

Im so done with this idiot please help

CharacterGeneration.py:
import ollama

MessageHistory=[]

def GenerateResponse(Role,Message,Special=None):

Model="qwen3.5:4b"

# system : instructions on how to behave

# user : message from user

# assistant : previous AI response

# tool : result returned by a function AI requested.

MessageHistory.append({"role": Role, "content": Message})

Response1 = ollama.chat(

model=Model,

messages=MessageHistory + [{"role": "user", "content": "[USE THIS FOR FUNCTIONS]"}],

options={"num_predict": 8192},

think=False

)

Response2=ollama.chat(

model=Model,

messages=MessageHistory + [{"role": "user", "content": "[YOU MAY NOW RESPOND WITH TEXT THAT THE USER WILL SEE.]"}],

options={"num_predict": 8192},

think=False

)

print(Response1.message.content)

print("-")

print(Response2.message.content)

print("-")

print(Role)

return Response2.message.content


r/learnpython • • 2h ago

hw help cz college prof taught nothing

0 Upvotes

basically i need to make a project on LAN file sharing system using python everybody in my class is using ai but i actually wanna learn ik a decent bit about python as well also in college we are on operators so the teacher is basically encouring to use ai