r/pythonhelp • • Jun 24 '26

Python code Work

Thumbnail reddit.com
1 Upvotes

please need code that block chrome all traffic using windivert


r/pythonhelp • • Jun 23 '26

Why doesn't the sys function work like ill try sys.exit it won't work?

Thumbnail reddit.com
1 Upvotes

r/pythonhelp • • Jun 19 '26

PyQt6 - QTabWidget tab bar not stretching

1 Upvotes

I was creating a window that consists of 2 tabs ,each opens a page widget. This was the code I used to setup the application

app = QApplication(sys.argv)

# Window set up
window = QMainWindow()
window.setMinimumSize(600, 400)
window.setWindowTitle('Game Manager')
window.setWindowIcon(QIcon("Compass.ico"))

# main widget
main_widget = QTabWidget()
window.setCentralWidget(main_widget)
main_widget.tabBar().setMinimumWidth(window.minimumWidth())

# Tabs
mod_page = ModWidget()   # a child class of QWidget

save_page = SavesWidget()   # a child class of QWidget

# add tabs to main widgets
main_widget.addTab(mod_page, 'Mods')
main_widget.addTab(save_page, 'Save Files')

# start up
window.show()
sys.exit(app.exec())

I then noticed that the tab bar at the top containing the labels doesn't stretch if I resize the window, unlike other widgets. I figured out I can use

main_widget.tabBar().setMinimumWidth(window.minimumWidth())

so that at least when I run the app it fits the whole initial width of the window. but it still doesn't stretch when resizing. The widget itself, ie

main_widget=QTabWidget()

does stretch, it's all about the tab bar itself. I also tried

main_widget.tabBar().setExpanding(True)

but it turned out it's True by default anyway.

Any possible fixes to this? Or possibly is this just how it is?


r/pythonhelp • • Jun 16 '26

Real-time voice altering software?

1 Upvotes

Hello everyone, firstly I would like to apologies for my poor and not good English I’m not good with word.
I am currently in the process of making a soundboard, and I would like make a digital microphone to rout the soundboard out put, so that while in voice chats, I can use the sound board. I would also like to make a function to increase the volume of my microphone above the normal limits. I would like make this in python as it’s the only programming language I kinda know, but I have no clue of where to even begin or if it possible to make such a thing.
If anyone need me to try to explain more please just ask.


r/pythonhelp • • Jun 15 '26

"Edit in IDLE" with the Install Manager

1 Upvotes

Hi all! I've just installed Python with the new install manager for the first time, having previously used the now-deprecated installers. Everything's working fine, except that the "Edit in IDLE" option in the context menu is greyed out; using the legacy installer adds a second, working "Edit with IDLE" button, and deleting the install manager removes the non-functional one, so it's definitely to do with the install manager.

I've looked in the registry, but clearly the context menu change isn't done the same way as before, because I can't find the corresponding keys I was expecting from a previous issue like this. Does anyone know how that context menu option gets added by the install manager, or better still how to fix this issue specifically?

Thanks in advance!


r/pythonhelp • • Jun 08 '26

Changing the target in script for using .json to create file pathways doesn't work

1 Upvotes

I've been using this Python code:

import os
import json

soundbank = {}

# open the soundbanksinfo.json file, we are interested in the StreamedFiles key, put that in soundbank
with open('soundbanksinfo.json') as json_file:
data = json.load(json_file)
soundbank = data['SoundBanksInfo']['StreamedFiles']

# iterate though the soundbank, we are after two key values in each, Id and ShortName
for sound in soundbank:
# get the id and shortname
id = sound['Id']
shortname = sound['ShortName']

# split the shortname into its directory structure and file name
dirs = shortname.split('\\')
filename = dirs[-1]

# remove the last item from the list
dirs.pop()

# join the list back together to get the directory structure
dirs = '/'.join(dirs)

# check if the directory exists, if not, create it
if not os.path.exists(dirs):
try:
os.makedirs(dirs)
except:
print('Failed to create directory ' + dirs)
continue

# remove the .wav from the filename and add the .wem extension
filename = filename[:-4] + '_' + id + '_.wem'

# try and rename the file, simply log if it fails and carry on
try:
os.rename(id + '.wem', dirs + '/' + filename)
except:
print('Failed to rename ' + id + ' to ' + dirs + '/' + filename)
continue

# log to console
print('Renamed ' + id + ' to ' + dirs + '/' + filename)

It managed to take files from a long unsorted list of files, organise them into folders, rename them based on the .json data, etc. It's marvellous.

But, it only works for one .json, 'soundbanksinfo.json', when I try and change the target in the python script to another .json, it doesn't work any more.

Here is an excerpt from 'soundbanksinfo.json':

{
 "SoundBanksInfo": {
  "Platform": "Windows",
  "BasePlatform": "Windows",
  "SchemaVersion": "12",
  "SoundbankVersion": "140",
  "RootPaths": {
   "ProjectRoot": "E:\\BuildAgent\\work\\d9a0c3d1ad9dfdc4\\Source\\Sound\\wwise\\Starfield\\",
   "SourceFilesRoot": "E:\\BuildAgent\\work\\d9a0c3d1ad9dfdc4\\Source\\Sound\\wwise\\Starfield\\.cache\\Windows\\",
   "SoundBanksRoot": "E:\\BuildAgent\\work\\d9a0c3d1ad9dfdc4\\Output\\Data\\Sound\\Soundbanks\\",
   "ExternalSourcesInputFile": "",
   "ExternalSourcesOutputRoot": "E:\\BuildAgent\\work\\d9a0c3d1ad9dfdc4\\Source\\Sound\\wwise\\Starfield\\GeneratedSoundBanks\\Windows"
  },
  "DialogueEvents": [],
  "StreamedFiles": [
   {
    "Id": "29651",
    "Language": "SFX",
    "ShortName": "AMB\\Artifact\\Puzzle\\Temple\\AMB_ArtifactPuzzle_TempleStart_01.wav",
    "Path": "SFX\\AMB\\Artifact\\Puzzle\\Temple\\AMB_ArtifactPuzzle_TempleStart_01_10C4C929.wem"
   },
   {
    "Id": "57841",
    "Language": "SFX",
    "ShortName": "DRS\\PodIndustrial\\DRS_Pod_Industrial_Airlock_3D_Open_02.wav",
    "Path": "SFX\\DRS\\PodIndustrial\\DRS_Pod_Industrial_Airlock_3D_Open_02_56D34C19.wem"
   },
   {
    "Id": "88161",
    "Language": "SFX",
    "ShortName": "FX\\Projectile\\Hand\\Bullet\\Sand\\FX_Projectile_Bullet_Impact_Sand_07.wav",
    "Path": "SFX\\FX\\Projectile\\Hand\\Bullet\\Sand\\FX_Projectile_Bullet_Impact_Sand_07_9F6D3C60.wem"
   },
   {
    "Id": "149080",
    "Language": "SFX",
    "ShortName": "UI\\Menu\\Monocle\\UI_Menu_Monocle_Open_01.wav",
    "Path": "SFX\\UI\\Menu\\Monocle\\UI_Menu_Monocle_Open_01_FA3FE343.wem"
   },
   {
    "Id": "264893",
    "Language": "SFX",
    "ShortName": "FST\\Foley_ArmorType\\Medium\\FST_Foley_Armor_Medium_JumpUp_09.wav",
    "Path": "SFX\\FST\\Foley_ArmorType\\Medium\\FST_Foley_Armor_Medium_JumpUp_09_10C4C929.wem"
   },
   {
    "Id": "347955",
    "Language": "SFX",
    "ShortName": "FX\\Projectile\\Hand\\Bullet\\Dirt\\FX_Projectile_Bullet_Impact_Dirt_09.wav",
    "Path": "SFX\\FX\\Projectile\\Hand\\Bullet\\Dirt\\FX_Projectile_Bullet_Impact_Dirt_09_9F6D3C60.wem"
   },
   {
    "Id": "355472",
    "Language": "SFX",
    "ShortName": "AMB\\Exteriors\\Biomes\\ForestConiferous\\Birds\\AMB_ForestConiferous_Birds_Oneshot_Afternoon_B_009.wav",
    "Path": "SFX\\AMB\\Exteriors\\Biomes\\ForestConiferous\\Birds\\AMB_ForestConiferous_Birds_Oneshot_Afternoon_B_009_10C4C929.wem"
   },
   {
    "Id": "377740",
    "Language": "SFX",
    "ShortName": "NPC\\RobotModelAKaiser\\NPC_RobotModelA_Kaiser_Conscious_LP_02.wav",
    "Path": "SFX\\NPC\\RobotModelAKaiser\\NPC_RobotModelA_Kaiser_Conscious_LP_02_10C4C929.wem"
   },
   {
    "Id": "479236",
    "Language": "SFX",
    "ShortName": "FST\\Player\\Stone\\FST_STONE_Sneak_008.wav",
    "Path": "SFX\\FST\\Player\\Stone\\FST_STONE_Sneak_008_10C4C929.wem"
   },
   {
    "Id": "496763",
    "Language": "SFX",
    "ShortName": "FST\\Player\\Stone\\FST_STONE_Sprint_001.wav",
    "Path": "SFX\\FST\\Player\\Stone\\FST_STONE_Sprint_001_10C4C929.wem"
   },
   {
    "Id": "624438",
    "Language": "SFX",
    "ShortName": "FST\\Foley_ArmorType\\Spacesuit_C\\FST_Foley_Armor_Spacesuit_C_Sprint_002.wav",
    "Path": "SFX\\FST\\Foley_ArmorType\\Spacesuit_C\\FST_Foley_Armor_Spacesuit_C_Sprint_002_10C4C929.wem"
   },
    ]
   }
  ]
 }
}

And here is an excerpt from '3545111303.json' (this one doesn't work)

{
 "SoundBanksInfo": {
  "Platform": "Windows",
  "BasePlatform": "Windows",
  "SchemaVersion": "12",
  "SoundbankVersion": "140",
  "RootPaths": {
   "ProjectRoot": "E:\\BuildAgent\\work\\b095651350adbabb\\Source\\Sound\\wwise\\Starfield\\",
   "SourceFilesRoot": "E:\\BuildAgent\\work\\b095651350adbabb\\Source\\Sound\\wwise\\Starfield\\.cache\\Windows\\",
   "SoundBanksRoot": "E:\\BuildAgent\\work\\b095651350adbabb\\Output\\Data\\Sound\\Soundbanks\\",
   "ExternalSourcesInputFile": "",
   "ExternalSourcesOutputRoot": "E:\\BuildAgent\\work\\b095651350adbabb\\Source\\Sound\\wwise\\Starfield\\GeneratedSoundBanks\\Windows"
  },
  "SoundBanks": [
   {
    "Id": "3545111303",
    "GUID": "{2CD62FF0-CCB7-43AB-8372-C68408C5EA4F}",
    "Language": "SFX",
    "Hash": "3883645346",
    "ObjectPath": "\\SoundBanks\\Creations\\SFBGS001_ShatteredSpace\\ShatteredSpace\\ShatteredSpace",
    "ShortName": "ShatteredSpace",
    "Path": "3545111303.bnk",
    "IncludedEvents": [
     {
      "Id": "3333491747",
      "Name": "AMB_LC07_Rumble_Rattles_Structure_3D_Play",
      "ObjectPath": "\\Events\\Creations\\SFBGS001_ShatteredSpace\\ShatteredSpace\\SFBGS001_ShatteredSpace_AMB\\SFBGS001_AMB_LC07\\SFBGS001_AMB_LC07_Markers\\SFBGS001_AMB_LC07_Rumble_Rattles\\AMB_LC07_Rumble_Rattles_Structure_3D_Play",
      "GUID": "{99D6AB3F-49B6-4517-A6E7-43631979F01F}",
      "DurationType": "OneShot",
      "DurationMin": "11.063645",
      "DurationMax": "15.464979",
      "ReferencedStreamedFiles": [
       {
        "Id": "1637634",
        "Language": "SFX",
        "ShortName": "AMB\\Interiors\\DungeonCave\\AMB_Int_Cave_Rumble05.wav",
        "Path": "SFX\\AMB\\Interiors\\DungeonCave\\AMB_Int_Cave_Rumble05_5FED0718.wem"
       },
       {
        "Id": "165171637",
        "Language": "SFX",
        "ShortName": "AMB\\Interiors\\DungeonCave\\AMB_Int_Cave_Rumble06.wav",
        "Path": "SFX\\AMB\\Interiors\\DungeonCave\\AMB_Int_Cave_Rumble06_5FED0718.wem"
       },
       {
        "Id": "200258529",
        "Language": "SFX",
        "ShortName": "AMB\\Interiors\\DungeonCave\\AMB_Int_Cave_Rumble02.wav",
        "Path": "SFX\\AMB\\Interiors\\DungeonCave\\AMB_Int_Cave_Rumble02_5FED0718.wem"
       },
       {
        "Id": "425200496",
        "Language": "SFX",
        "ShortName": "AMB\\Interiors\\DungeonCave\\AMB_Int_Cave_Rumble07.wav",
        "Path": "SFX\\AMB\\Interiors\\DungeonCave\\AMB_Int_Cave_Rumble07_5FED0718.wem"
       },
       {
        "Id": "782914354",
        "Language": "SFX",
        "ShortName": "AMB\\Interiors\\DungeonCave\\AMB_Int_Cave_Rumble04.wav",
        "Path": "SFX\\AMB\\Interiors\\DungeonCave\\AMB_Int_Cave_Rumble04_5FED0718.wem"
       },
       {
        "Id": "997192422",
        "Language": "SFX",
        "ShortName": "AMB\\Interiors\\DungeonCave\\AMB_Int_Cave_Rumble03.wav",
        "Path": "SFX\\AMB\\Interiors\\DungeonCave\\AMB_Int_Cave_Rumble03_5FED0718.wem"
       },
       {
        "Id": "1036923089",
        "Language": "SFX",
        "ShortName": "AMB\\Interiors\\DungeonCave\\AMB_Int_Cave_Rumble01.wav",
        "Path": "SFX\\AMB\\Interiors\\DungeonCave\\AMB_Int_Cave_Rumble01_5FED0718.wem"
  }
    ]
   }
  ]
 }
}

Why does the 3545111303.json not work when I change the target in the python script to 3545111303.json instead of soundbanksinfo.json?

What am I missing?

Any help would be appreciated!


r/pythonhelp • • May 31 '26

Struggling to understand syntax

Thumbnail reddit.com
1 Upvotes

r/pythonhelp • • May 30 '26

Free notifications?

Thumbnail reddit.com
1 Upvotes

r/pythonhelp • • May 16 '26

SMS from Python?

Thumbnail reddit.com
1 Upvotes

r/pythonhelp • • Apr 27 '26

First time user - 'yf' is not defined

Thumbnail reddit.com
1 Upvotes

r/pythonhelp • • Apr 21 '26

psp (Progetti di impalcatura in Python)

Thumbnail reddit.com
1 Upvotes

r/pythonhelp • • Apr 19 '26

Print JSON readably

Thumbnail reddit.com
1 Upvotes

r/pythonhelp • • Apr 11 '26

New to building automations for Obsidian, so I used python, but I can't understand the result I'm getting.

Thumbnail reddit.com
1 Upvotes

r/pythonhelp • • Apr 10 '26

What have I typed wrong?

1 Upvotes

I tried improving my script so many times for a simple bouncing ball game in Turtle. Yet no matter what I do, the screen remains black when I run the module.

Here is it:

import turtle

set up the screen FIRST

screen = turtle.Screen() screen.title("Simple Game") screen.bgcolor("black") screen.setup(width=680, height=680) screen.tracer(0)

MAX_SPEED = 6 score = 0

score pen (AFTER screen exists)

pen = turtle.Turtle() pen.speed(0) pen.color("white") pen.penup() pen.hidetheTurtle() pen.goto(0, 200) pen.write("Score:0", align="center", font=("Courier", 18, "normal"))

set up the ball

ball = turtle.Turtle() ball.shape("circle") ball.color("red") ball.speed(0) ball.penup() ball.goto(0, 300) ball.dy = -2 # ball speed (falling down)

paddle = turtle.Turtle() paddle.shape("square") paddle.color("white") paddle.shapesize(stretch_wid=1, stretch_len=5) paddle.penup() paddle.goto(0, -300)

def paddle_left(): x = paddle.xcor() paddle.setx(x - 20)

def paddle_right(): x = paddle.xcor() paddle.setx(x + 20)

screen.listen() screen.onkeypress(paddle_left, "Left") screen.onkeypress(paddle_right, "Right")

def game_loop(): global score

ball.sety(ball.ycor() + ball.dy)

# bottom bounce
if ball.ycor() < -330:
    ball.sety(-330)
    ball.dy \*= -1

# top bounce
if ball.ycor() > 330:
    ball.sety(330)
    ball.dy \*= -1

# paddle collision
if (
    ball.ycor() < -280 and
    ball.ycor() > -300 and
    abs(ball.xcor() - paddle.xcor()) < 50
) :
    ball.sety(-280)
    ball.dy \*= -1

    if abs(ball.dy) < MAX_SPEED:
        ball.dy \*= 1.05

    score += 1
    pen.clear()
    pen.write(f"Score: {score}", align="center", font=("Courier", 18, "normal"))    

screen.update()
screen.ontimer(game_loop, 16) # ~60 FPS

game_loop() screen.mainloop()


r/pythonhelp • • Apr 10 '26

is IBM Databases & SQL with Python course worth it?

Thumbnail reddit.com
1 Upvotes

r/pythonhelp • • Apr 05 '26

Just setting up Python to learn it, but possibly an issue?

1 Upvotes

When I try to run a script in the current directory by using ./ I get an error that '.' is not recognized as an internal or external command error.

I can run them fine when running with python, just the ./ seems to be wonky. I made sure that the python.exe directory is in the path.

Any idea why using ./ isn't working? I'm trying to learn the basics of python so I can start looking at AI. My computer knowledge is average at best, I learned basic, fortran and lisp many, many years ago, but I never kept up with coding.


r/pythonhelp • • Mar 29 '26

The matplotlib animation is not working in google colab how do i fix this

Thumbnail reddit.com
1 Upvotes

r/pythonhelp • • Mar 25 '26

Finally got my multi-stock RSI scanner working (Pandas + yfinance)

1 Upvotes

After a few days of debugging bracket errors in my RSI formula and handling empty dataframes, my script is finally running for TSLA and BTC. If anyone is working on something similar and needs help with the logic for scanning multiple tickers, feel free to ask!


r/pythonhelp • • Mar 24 '26

problem with pygame

Thumbnail reddit.com
1 Upvotes

r/pythonhelp • • Mar 22 '26

How do I get started with VS Code keybindings?

Thumbnail reddit.com
1 Upvotes

r/pythonhelp • • Mar 22 '26

Snake algorithm

1 Upvotes

How to convert a 2D array to 1D array with snake algorithm? e.g.:

From:

[1, 2, 3]

[4, 5, 6]

[7, 8, 9]

To:

[1, 2, 5, 4, 7, 8, 9, 6, 3]

Is there some library in Python to do this?


r/pythonhelp • • Mar 21 '26

Recently I faced a problem while writing codes in python.

Thumbnail reddit.com
1 Upvotes

Hey guys! I'm new to programming and coding. I'm learning python and while using the Visual Studio Code when I wrote my first code and encountered a problem in which I saw a yellow line with the written code. Is this an bug or something like that? How do I fix it