Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Combine console script + GUI (tkinter)
Post: RE: Combine console script + GUI (tkinter)

This is a low rent way of doing what you want with the dialog. import ttkbootstrap as ttk def get_dates(start=None, end=None): """Draw dialog for selecting two dates.""" root = ttk.Window() ...
deanhystad General Coding Help 2 173 Yesterday, 01:00 PM
    Thread: problem in using unittest
Post: RE: problem in using unittest

ZeroDIvisionError is not defined. Carefully check the case.
deanhystad General Coding Help 2 86 Yesterday, 12:51 PM
    Thread: Operation result class
Post: RE: Operation result class

I think it is more "pythonic" to use exceptions. This looks like C++ code. Using exceptions: class ErrorException(Exception): """For when everything goes wrong.""" class WarningException(Excep...
deanhystad General Coding Help 6 222 Feb-24-2024, 05:27 PM
    Thread: Decorators @ annotation
Post: RE: Decorators @ annotation

These are the decorators that I use: Often @classmethod @staticmethod @property Less often @dataclass @ABC.abstractmethod @functools.singledispatchmethod @typing.overload Other than those, I don't ...
deanhystad General Coding Help 3 150 Feb-23-2024, 11:49 PM
    Thread: fast MCTS in Python
Post: RE: fast MCTS in Python

What have you tried so far? fast and efficient are attributes, not metrics. Knowing what you tried will help gauge what kind of performance you think is slow.
deanhystad General Coding Help 1 98 Feb-23-2024, 10:21 PM
    Thread: Showing windows after one another
Post: RE: Showing windows after one another

You can call Tk() more than once. I do that here to display all the png files in my games folder. import tkinter as tk from pathlib import Path class ShowImage(tk.Tk): def __init__(self, image_f...
deanhystad GUI 4 214 Feb-23-2024, 10:16 PM
    Thread: Showing windows after one another
Post: RE: Showing windows after one another

quit() exits mainloop. It does not destroy the window. You can see that in the example below. import tkinter as tk class Class1(tk.Tk): def __init__(self, *args, **kwargs): super().__in...
deanhystad GUI 4 214 Feb-22-2024, 07:11 PM
    Thread: Horizontal extension of widgets + frame size adapted to content
Post: RE: Horizontal extension of widgets + frame size a...

You don't need, nor even want, to use a canvas to scroll the tree. This will have the undesired effect of scrolling the column headers so they are not always visible. The tree widget knows how to wo...
deanhystad GUI 3 165 Feb-22-2024, 06:54 PM
    Thread: Combine console script + GUI (tkinter)
Post: RE: Combine console script + GUI (tkinter)

dater.py creates a window when it is imported in your script. A second dater.py is created when you run(["python", "dater.py"]). I would import dater.py and create an instance from the script instea...
deanhystad General Coding Help 2 173 Feb-22-2024, 12:02 AM
    Thread: Unable to download TLS Report attachment
Post: RE: Unable to download TLS Report attachment

Please post the entire error message and traceback.
deanhystad General Coding Help 6 231 Feb-21-2024, 08:14 PM
    Thread: string to float conversion fails
Post: RE: string to float conversion fails

I guess the desired behavior is if user enters nothing, the program should return 0 instead of raising an exception. This is not what float(str) does. Float raises an exception when the str is not a...
deanhystad Homework 8 289 Feb-21-2024, 06:34 PM
    Thread: string to float conversion fails
Post: RE: string to float conversion fails

float("0") will return 0 because "0" is a numeric string representing the number 0. "" is not "0", and "" is not a string that represents any number. float(str) and int(str) raise a value error when...
deanhystad Homework 8 289 Feb-21-2024, 05:12 PM
    Thread: Puzzling import issue that I have no idea how to solvr
Post: RE: Puzzling import issue that I have no idea how ...

You cannot do this: from microservice.service.repository import clients, secrets, alerts clients = ...some code using the data...This code creates a variable named "clients" in the local module. If...
deanhystad General Coding Help 3 281 Feb-21-2024, 05:07 PM
    Thread: Using OpenCV and image path is invalid
Post: RE: Using OpenCV and image path is invalid

Do not use "\" as a path separator. "\" is used to start escape sequences in a string literal, so using it as a path separator can cause a lot of confusion. Use "/" or "\\" instead. you can also u...
deanhystad General Coding Help 3 199 Feb-21-2024, 04:49 PM
    Thread: p[0] mysteriouly set to 0
Post: RE: p[0] mysteriouly set to 0

When I run your code it iterates several times before reaching zero.
deanhystad General Coding Help 2 152 Feb-21-2024, 04:28 AM
    Thread: I have 'Failed: DID NOT RAISE <class 'Exception'>'
Post: RE: I have 'Failed: DID NOT RAISE <class 'Exceptio...

Thos are not "Errors", those are failed tests. The test complains because this does not raise an exception. with pytest.raises(Exception): Image(1, 1, [(0, 0, 0)])(0, 0, 0) is a valid pix...
deanhystad Homework 3 241 Feb-20-2024, 05:34 PM
    Thread: Transform a list
Post: RE: Transform a list

This looks interesting. It extracts the bookmarks directly from the PDF file in the form of a dictionary. https://stackoverflow.com/questions/5430...genumber-a You could use regex to split your boo...
deanhystad Data Science 3 194 Feb-19-2024, 09:03 PM
    Thread: Need to upgrade this code.
Post: RE: Need to upgrade this code.

You become proficient by doing. You have the code for shrink. Write it in the form of a class. expand is easier than shrink, so it should be no challenge.
deanhystad Homework 1 128 Feb-19-2024, 08:05 PM
    Thread: The function of double underscore back and front in a class function name?
Post: RE: The function of double underscore back and fro...

Not quite. calculate_gas_milage() would try to call a function named calculate_gas_milage and return a result. This would either raise a NameError, or map "efficiency" to the result, not the functio...
deanhystad General Coding Help 9 413 Feb-19-2024, 03:51 PM
    Thread: Fastest way tkinter
Post: RE: Fastest way tkinter

When you compute the path, make the obstacles wider/longer by half the width of the robot.
deanhystad General Coding Help 2 269 Feb-19-2024, 04:31 AM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020