Skip to main content
Filter by
Sorted by
Tagged with
2 votes
0 answers
66 views

I was trying to make a subclass that acts like the original but its go function returned the string of the text of the button, instead of the index of the button. My own defined subclass makes the ...
Randumb_ASH's user avatar
-1 votes
1 answer
70 views

I am trying to get the entered value from an entry widget to record in a text file, I've tried a lot but am not sure where to go from here. It come up with this Error: Exception in Tkinter callback ...
user30428193's user avatar
1 vote
0 answers
109 views

In my class, I have some methods that can be overridden by subclasses, but do not need to be. I like to test my project and generate a coverage report using coverage.py. Because the method of the ...
502E532E's user avatar
  • 591
0 votes
0 answers
43 views

Consider the following code, if you will: class ParentService: BASE_DIR = '/some/path' class Results(str, Enum): RESULT1 = 'ResultOne.xlsx' RESULT2 = 'ResultTwo.pdf' ...
zkvvoob's user avatar
  • 506
2 votes
1 answer
277 views

I am implementing a series of classes in Equinox to enable taking derivatives with respect to the class parameters. Most of the time, the user will be instantiating class A and using the fn function ...
JamesVR's user avatar
  • 173
-2 votes
2 answers
67 views

I'm trying to create a bot Discord with Python. I created a class MyBot like this: import discord from discord.ext import commands intents = discord.Intents.all() intents.members = True class MyBot(...
Toniixav's user avatar
1 vote
1 answer
46 views

I have a class for a GUI with two radio buttons one to set save_to_excel to True and the other to False. However I wanted to add a loading screen using threading, but when I add that second class the ...
usherא's user avatar
  • 21
0 votes
1 answer
50 views

import pygame from math import radians, sin, cos from datetime import datetime class Clock: def __init__(self): self.width, self.height = 800, 800 self.white = (255, 255, 255) ...
Mohamad Homaei's user avatar
1 vote
1 answer
63 views

I have a parent dataclass, and various other classes will then extend this parent dataclass. Let's call these dataclasses DCs. In the example code below, see ParentDC, and an example ChildDC: from ...
bzm3r's user avatar
  • 4,674
0 votes
1 answer
60 views

First up, I'm really pretty bad at OOP and tkinter/customtkinter and this is only my third project I've built with classes over straight functions, so please excuse my mess. I'm getting there, and ...
nannerpuss's user avatar
0 votes
2 answers
74 views

I want a decorator that I can use as both @decorator and decorator() with class methods, like this : def decorator_with_args(name): print(f'Hello {name} !') def decorator(func): def ...
Prasun Kumar Khan's user avatar
0 votes
0 answers
37 views

import tkinter as tk import math,time,random from PIL import ImageTk, Image,ImageEnhance start_time = time.time() window = tk.Tk() window.geometry("300x300") canvas = tk.Canvas(window, ...
MeHocha 333's user avatar
1 vote
3 answers
91 views

import tkinter as tk from PIL import ImageTk, Image window = tk.Tk() window.geometry("300x300") canvas = tk.Canvas(window, width=300, height=300,bg="red") canvas.pack() class ...
MeHocha 333's user avatar
0 votes
0 answers
360 views

I am trying to upgrade the OpenAI 0.28 version to 1.2.2. For doing that I defined the client and replaced the openai chatcompletion with client. Below is the constant file which will be used in the ...
Pushpendra Singh's user avatar
0 votes
1 answer
43 views

What I'd like to achieve is: b.py(might be in a third party package I cannot modify): from xxx import A class B: def __init__(): self.a = A() The file I actually execute: execute.py ...
Feephy's user avatar
  • 143
0 votes
3 answers
65 views

For a class (snake class) created from the turtle module in Python: Problem 1. when the move() method is called, the snake segments are moving backwards instead of forward . The problem seems to be ...
chris's user avatar
  • 23
-1 votes
1 answer
102 views

I'm trying to add class variable values to a list inside a function, but I'm not seeing any errors or the expected output? The comboxbox doesn't display when I uncomment the list code. Outside of the ...
James-Jesse Drinkard's user avatar
0 votes
0 answers
41 views

I'm not an expert python programmer. After some time and effort I've built a tkinter UI that properly works. Recently, I've found myself needing to add a scrollbar inside the frame, since I need to ...
Elia Melloni's user avatar
0 votes
3 answers
125 views

I'm trying to wrap two threaded functions inside an object and run a couple of instances of the object. So far I could only run the objects if I pull the threading outside the class. import threading ...
R.Orteza's user avatar
0 votes
2 answers
940 views

Is there an elegant way to list all properties defined on a Pydantic BaseModel? It's possible to extract the list of fields via BaseModel.model_fields and the list of computed fields via BaseModel....
SultanOrazbayev's user avatar
1 vote
2 answers
133 views

I have the following situation: A module that contains a class Foo with some additional convenience functions for assembling Foo objects. A Foo object contains methods for interacting with data in an ...
Ash's user avatar
  • 205
0 votes
1 answer
165 views

New to python and trying to create an app with customtkinter. The app lets users pick values from different drop-downs and generates codes based on the chosen value. Updated per comment from Mike-SMT: ...
Gautam's user avatar
  • 2,763
4 votes
3 answers
253 views

In Python, how do I correctly define a classmethod of a parent class that references an attribute of a child class? from enum import Enum class LabelledEnum(Enum): @classmethod def list_labels(...
SultanOrazbayev's user avatar
2 votes
1 answer
51 views

Defining a class of instance variable from commonly used fields in API response by looping through each JSON record self.id=response['identifier'] -->output: 1234 self.name=response['...
Victor's user avatar
  • 23
0 votes
0 answers
244 views

these codes were running flawlessly on tensorflow==2.15, for the purpose of GPU acceleration, I switched to tensorflow-gpu == 2.10.1 with keras 2.10, respectively. and this ValueError raised up on my ...
pepCoder's user avatar
  • 329
1 vote
1 answer
167 views

I am trying to run a simple code in ROS to create a subscriber and a publisher using classes in python. I am new to using classes in python and I am not sure what I am doing wrong here. Below is the ...
Sabyasachi's user avatar
0 votes
0 answers
45 views

I have two classes Player and LineUp, one is used within the other (shown below). I am trying to update my LineUp class after I have already instantiated it. class Player: def __init__(self, ...
PureSlurp's user avatar
0 votes
2 answers
77 views

Is it possible to retain a reference to the parent object when creating an instance of a nested class through the outer object, without explicitly passing the parent object as an argument? class ...
Japan Manul's user avatar
0 votes
1 answer
48 views

What informs the code that The relationship between the Franchise and Menu classes is that The Franchise class has an attribute menus that stores instances of the Menu class, when clearly Menu and ...
Joseph Matheri's user avatar
0 votes
1 answer
75 views

I am trying to build a splash screen that I will be able to call from an external application using Tkinter. I'd like to define my GUI in a class, like this: class Splash: def __init__(self): ...
Ben Zelnick's user avatar
0 votes
1 answer
555 views

I'm facing an issue while working with a custom class in Python. I have a module named 'my_module' with a class called 'MyClass'. However, when I try to instantiate the class in another script or ...
Albin Siby's user avatar
-2 votes
1 answer
484 views

The problem is although i can see the method I'm calling, the error says I don't have a method the way I call. Here is the error: Traceback (most recent call last): File "C:\Users\htuna\...
Selim's user avatar
  • 1
0 votes
0 answers
31 views

I am using boto3 library to establish connection to an s3 compatible storage. I had created a class with constructor that take cluster details, access key & IDs as inputs, having these initiated. ...
vpothurajula's user avatar
0 votes
1 answer
80 views

I have this piece of code, part of a Spikingjelly neural network training functionality, which gets some errors on this line after running. I'm not quite experienced in Python, and I don't understand ...
Marziye Hasanshahi's user avatar
-2 votes
2 answers
124 views

from dataclasses import dataclass @dataclass class ThreeDPoint: x: int | float y = 0.0 z: int | float = 0.0 point_1 = ThreeDPoint(1.0,2) point_3 = ThreeDPoint(1,2) print(point_1 == ...
anonNEWlearner's user avatar
0 votes
1 answer
58 views

I have written a script, that automatically adds a property to a class. It works, but currently I can not test it. The code is shown below, but can also be seen on GitHub. See the class Cat, the ...
Watchduck's user avatar
  • 1,219
0 votes
0 answers
33 views

I'm have an unexpected problem. This is a random example, but describe the problem it self. With this code: class Location: def __init__(self, name: str) -> None: self.name = name ...
Miguel A. Díaz Castillo's user avatar
0 votes
1 answer
693 views

I want to automate a class method which would be called right after __init__ has completed. e.g, class A: def __init__(self): initialization statement def post_init(self): #...
atskdev's user avatar
0 votes
2 answers
884 views

I've got a class and would like to apply a decorator to all functions within that class without having to add a function decorator to every single function. I know that there are solutions like the ...
Strawbert's user avatar
-1 votes
2 answers
138 views

I am trying to build a small UI for updating some settings and then displaying some intake data on a raspberrypi. Python version is 3.9.2. The most logical way to save the settings I thought would be ...
Shenanigator's user avatar
  • 1,086
0 votes
2 answers
48 views

I am trying to make a program in which you can draw different shapes. I already managed to embed the turtlescreen into my already existing Tkinter one (root) and got a Tkinter Menu, in which I can run ...
Akemi's user avatar
  • 1
1 vote
1 answer
147 views

I am trying to create a kind of dataframe subclass with inheritance of polars.DataFrame. I would like to modify the __setitem__ method to make following statement possible: df['test_column'] = 'test' ...
KYPcode's user avatar
  • 81
0 votes
1 answer
155 views

I am trying to run the below code using dataflow, where I have 2-3 functions defined inside a class, out of which 2 functions are working but the send_email() is working nor throwing any errors. ...
Sandeep Mohanty's user avatar
0 votes
3 answers
127 views

The following code was supposed to clarify how Python class variables behave,but somehow it opens more questions than it solves. The class Bodyguard has the variable protect, which is a list that by ...
Watchduck's user avatar
  • 1,219
-1 votes
1 answer
80 views

Here's the complete class code with an example of its implementation. import tensorflow as tf import numpy as np import time from tensorflow.keras.applications.inception_v3 import InceptionV3 from ...
fares rs's user avatar
0 votes
0 answers
80 views

I'm having trouble creating a results page for a tkinter GUI that I've made. The problem is that the page2 file has to import the page3 file in order to go to page3 when clicked with a button. In the ...
JimV's user avatar
  • 11
2 votes
1 answer
2k views

I am trying to set a permanent attribute on a class to be used by other methods throughout the life of the instance of the class class Test: @cached_property def datafile_num_rows(self) -> ...
metersk's user avatar
  • 12.7k
0 votes
1 answer
55 views

I know that private attributes are loosely defined in Python, but I'm trying to figure out what would be the most lean way of implementing a method to merge together private attributes. Class Event: ...
unitrium's user avatar
1 vote
2 answers
217 views

I am trying to add a button to toolbar. The button is a custom class that inherits ToolToggleBase. In my custom SelectButton class, I want to pass few arguments, but I getting an error: import numpy ...
Alon123's user avatar
  • 174
1 vote
1 answer
1k views

I have a class which will manage multiple pandas Data Frames. The Data frames are class properties. I have initiated every Data Frame in the class constructor and assigned an empty Data Frame to them (...
Diaco's user avatar
  • 38

1
2 3 4 5
11