Re: Extract lines from file, add to new files

2024-01-31 Thread Rich Shepard via Python-list

On Tue, 30 Jan 2024, Thomas Passin via Python-list wrote:


If I had a script that's been working for 30 years, I'd probably just use
Python to do the personalizing and let the rest of the bash script do the
rest, like it always has. The Python program would pipe or send the
personalized messages to the rest of the bash program. Something in that
ballpark, anyway.


Thomas,

A bash shell script looks easier for me and more promising. Using a while
loop (one for the name file the other for the address file), and sed for
putting the name at the head of the message replacing a generic placeholder
should work with the existing for loop script.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Aw: Re: Re: Extract lines from file, add to new files

2024-01-30 Thread Rich Shepard via Python-list

On Tue, 30 Jan 2024, Karsten Hilbert wrote:


It doesn't need to. It just sends the (pre-personalized-by-Python) mail files.


Karsten,

In which case, I might as well have Python format and send the messages. :-)

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Aw: Re: Extract lines from file, add to new files

2024-01-30 Thread Rich Shepard via Python-list

On Tue, 30 Jan 2024, Karsten Hilbert wrote:


Why not foxus on just the part you think you are better off using python,
namely personalization ?

Create personalized files and send them with your trusted mailx solution ?


Karsten,

Too much time. And while mailx accepts the '-a' option for attachments but
has none for individual salutations.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


RE: Extract lines from file, add to new files

2024-01-30 Thread Rich Shepard via Python-list

On Tue, 30 Jan 2024, AVI GROSS via Python-list wrote:


But seriously, the OP, AKA Rich, is making clear that he is making a tool
for his own use. It sounds like he wants to maintain a data repository of
his own with some info about his clients and then have the ability to
specify a name and pop up an email directed to them, or something along
those lines.


Close, Avi.

I have no issues sending messages to single individuals or mailing lists. I
want to send the same message to several individuals at one time, which I've
done -- without individual salutations -- for 30 years using a bash script
and mailx.

As I replied to Thomas on the list, I've downloaded 11 PDF docs from the Web
(and a useful book on the Python3 standard library) and will start reading
and learning from them today. I expect to find answers to my few remaining
questions in these docs.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Extract lines from file, add to new files

2024-01-30 Thread Rich Shepard via Python-list

On Tue, 30 Jan 2024, Thomas Passin via Python-list wrote:


Fine, my toy example will still be applicable. But, you know, you haven't
told us enough to give you help. Do you want to replace text from values
in a file? That's been covered. Do you want to send the messages using
those libraries? You haven't said what you don't know how to do. Something
else? What is it that you want to do that you don't know how?


Thomas,

For 30 years I've used a bash script using mailx to send messages to a list
of recipients. They have no salutation to personalize each one. Since I want
to add that personalized salutation I decided to write a python script to
replace the bash script.

I have collected 11 docs explaining the smtplib and email modules and
providing example scripts to apply them to send multiple individual messages
with salutations and attachments.

Today I'm going to be reading these. They each recommend using .csv input
files for names and addresses. My first search is learning whether I can
write a single .csv file such as:
"name1","address1"
"mane2","address2"
which I believe will work; and by inserting at the top of the message block
Hi, {yourname}
the name in the .csv file will replace the bracketed place holder.

Still much to learn and the batch of downloaded PDF files should educate me.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Extract lines from file, add to new files

2024-01-30 Thread Rich Shepard via Python-list

On Mon, 29 Jan 2024, Thomas Passin via Python-list wrote:


If you aren't going to use one or another existing template system,
perhaps the easiest is to use unique strings in the message file. For
example:

Dear __##so-and-so##__:
  Please don't write this message off as mere spam.
  Respectfully, Rich

Then you just do a replace of the unique string by the salutation. Don't
change the original (i.e., template), make the changes to a copy that you
will output.


My script is not a web application, but an emailer that allows me to contact
clients and prospective clients. From the command line on a linux host.
Using the python smtplib and mail modules.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


RE: Extract lines from file, add to new files

2024-01-29 Thread Rich Shepard via Python-list

On Mon, 29 Jan 2024, avi.e.gr...@gmail.com wrote:


There are several general solutions that may apply. Some involve reading
in both files into data structures and perhaps linking them together in
some way such as a data.frame or binary tree. You can then process
individual request in memory/


Avi,

I found several web pages describing how to use the python email library and
tools to send individual or multiple email messages. I'll learn how to do
this based on a couple of detailed examples.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


RE: Extract lines from file, add to new files [RESOLVED]

2024-01-29 Thread Rich Shepard via Python-list

On Mon, 29 Jan 2024, Rich Shepard via Python-list wrote:


I'll keep searching for a solution.


IIRC, someone here pointed me to <https://realpython.com/python-send-email/>
and I forgot about it ... until now.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


RE: Extract lines from file, add to new files

2024-01-29 Thread Rich Shepard via Python-list

On Mon, 29 Jan 2024, Rich Shepard via Python-list wrote:


No, I hadn't ... but I am reading it now.


Perhaps I missed the answer to my question when reading the io module. It
explains how to open/write/read files of text and binary data, not passing
a variable's value from one file to a place-keeper in another file.

I'll keep searching for a solution.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


RE: Extract lines from file, add to new files

2024-01-29 Thread Rich Shepard via Python-list

On Mon, 29 Jan 2024, dieter.mau...@online.de wrote:


Have you read "https://docs.python.org/3/library/io.html#module-io";?


Dieter,

No, I hadn't ... but I am reading it now.

Many thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


RE: Extract lines from file, add to new files

2024-01-29 Thread Rich Shepard via Python-list

On Fri, 12 Jan 2024, Rich Shepard via Python-list wrote:


For my use 1) the salutation and email address (always with an '@') are
sequential and 2) I'm developing the script to extract both from the same
file.


I've looked at my Python books "Python Crash Course," "Effective Python,"
and "Python Tricks The Book" as well as web pages in my searches without
finding the answer to what may be a simple question: how to specify a
variable in one file that has its values in another file.

Specifically, how to I designate the salutation holder in the message file
and pass it the name value from the name/email address file?

If this explanation is not sufficiently clear I'll re-write it. :-)

TIA,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


RE: Extract lines from file, add to new files

2024-01-12 Thread Rich Shepard via Python-list

On Fri, 12 Jan 2024, AVI GROSS via Python-list wrote:


But is the solution a good one for some purpose? The two output files may
end up being out of sync for all kinds of reasons. One of many "errors"
can happen if multiple lines in a row do not have an "@" or a person's
name does, for example. What if someone supplied more than one email
address with a comma separator? This may not be expected but could cause
problems.


Avi,

For my use 1) the salutation and email address (always with an '@') are
sequential and 2) I'm developing the script to extract both from the same
file.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Extract lines from file, add to new files

2024-01-11 Thread Rich Shepard via Python-list

On Thu, 11 Jan 2024, Piergiorgio Sartor via Python-list wrote:


Why not to use bash script for all?


Piergiorgio,

That's certainly a possibility, and may well be better than python for this
task.

Thank you,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Extract lines from file, add to new files

2024-01-11 Thread Rich Shepard via Python-list

On Thu, 11 Jan 2024, Mats Wichmann via Python-list wrote:


4. Don't assume it's going to be "plain text" if the email info is
harvested from external sources (like incoming emails) - you'll end up
stumbling over a 誰かのユーザー from somewhere. Process as bytes, or be
really careful about which encodings you allow - which for email "names"
is something you can't actually control.


Mats,

Not an issue for me.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Extract lines from file, add to new files

2024-01-11 Thread Rich Shepard via Python-list

On Thu, 11 Jan 2024, MRAB via Python-list wrote:


From the look of it:
1. If the line is empty, ignore it.
2. If the line contains "@", it's an email address.
3. Otherwise, it's a name.


MRAB,

Thanks. I'll take it from here.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Extract lines from file, add to new files

2024-01-11 Thread Rich Shepard via Python-list

It's been several years since I've needed to write a python script so I'm
asking for advice to get me started with a brief script to separate names
and email addresses in one file into two separate files: salutation.txt and
emails.txt.

An example of the input file:

Calvin
cal...@example.com

Hobbs
ho...@some.com

Nancy
na...@herown.com

Sluggo
slu...@another.com

Having extracted salutations and addresses I'll write a bash script using
sed and mailx to associate a message file with each name and email address.

I'm unsure where to start given my lack of recent experience.

TIA,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cannot install pkg_resources using pip

2023-04-17 Thread Rich Shepard

On Mon, 17 Apr 2023, aapost wrote:


Slackware isn't as straight forward in it's management as other distros
(not standardized anyway).


I've used Slackware for 20 years; it's completely rationale and comfortable
for me. :-)


That being said, if you start from python source ...


If worse came to worse, I'd reinstall the distro package.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cannot install pkg_resources using pip [RESOLVED]

2023-04-17 Thread Rich Shepard

On Sun, 16 Apr 2023, Rich Shepard wrote:


How do I clean this up?


My thanks for the suggestions and ideas you sent me on this issue. I've
resolved it by not trying to build pulseaudio-equalizer. I don't need it
because I learned this morning that my Yamaha CM500 headset clearly heard
the Zoom audio test tones and voices on a YouTube video.

I'm testing the headset on a Zoom call this afternoon with a friend.
Assuming it works with the meeting as it did on the Zoom test I'll use it
for Zoom and Jitsi meetings and use the Marantz Pro mic and Panasonic
headphones for recording web tutorials and podcasts.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cannot install pkg_resources using pip

2023-04-17 Thread Rich Shepard

On Sun, 16 Apr 2023, Thomas Passin wrote:


Sorry, Rich, I've never dealt with this so someone else will have to give
suggestions.


Thomas,

This is all new to me, too.


I would try to see if there are any versions available. It could be that
meson says it needs version x but only version y > x is available. Pip
will quit but meson may very well work with the available version anyway.
So I would try to install pkg_resources on its own, and then see if the
meson build can succeed. No guarantees, but I've seen this work before. So
python3.9 -m pip install --user pkg_resources

Or, to see what versions if any are available:
python3.9 -m pip install --user pkg_resources==
# NO spaces allowed before the "==".


Thank you. I'll give this a try.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cannot install pkg_resources using pip

2023-04-16 Thread Rich Shepard

On Sun, 16 Apr 2023, Rich Shepard wrote:


I'll download the installer from there.


But, I still cannot install the pkg_resources module that meson wants to
start the build of pulseaudio-equalizer:
# pip install pkg_resources
ERROR: Could not find a version that satisfies the requirement pkg_resources 
(from versions: none)
ERROR: No matching distribution found for pkg_resources

Rich

--
https://mail.python.org/mailman/listinfo/python-list


Re: Cannot install pkg_resources using pip

2023-04-16 Thread Rich Shepard

On Sun, 16 Apr 2023, Thomas Passin wrote:


It worked then because your path found a pip script. When there are more
than one Python installations, it can be unclear which one will get run,
depending on how the path got set up after the last version was installed.


Thomas,

I probably last used pip with a python-3.7 version.


To check your version of Python, run
python3 -V


$ python3 -V
Python 3.9.10


Then try to run pip:
python3.9 -m pip


$ python3.9 -m pip
/usr/bin/python3.9: No module named pip

If pip has not been installed (very possible on Linux), then you will need to 
get it.  If python3.9 is not the system-upgraded version, then do an internet 
search for "linux python install pip". There's a pip website that has an 
installer for it. I never remember what it's called, so I always have to 
search for it myself.


https://www.redhat.com/sysadmin/install-python-pip-linux

I'll download the installer from ther.

If it appears that python3.9 *is* the version installed by the system, then 
use the system installer to install the right version of pip - as I said 
above, the package name can vary across distros.


It should have been installed with the upgrade to 3.9.10


Your message doesn't seem to have been copied to the mailing list. If you
don't mind, it could help other people if you copied it and this reply to
the list.


I always respond to the mail list if that's the 'reply to' address.
Sometimes I don't check the address used in my reply, assuming it's correct.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Cannot install pkg_resources using pip

2023-04-16 Thread Rich Shepard

Python3-3.9.10 installed on this Slackware64-14.2 desktop. Trying to run
meson to build an application I'm told it's missing pkg_resources, which is
part of setuptools. The command fails:
# pip install setuptools
bash: /usr/bin/pip: /usr/bin/python3.7: bad interpreter: No such file or 
directory

There is no python3.7 here:
# ls /usr/bin/python3.7
ls: cannot access '/usr/bin/python3.7': No such file or directory

How do I clean this up?

TIA,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread Rich Shepard

On Mon, 13 Mar 2023, Thomas Passin wrote:


No doubt, depending on the data formats used. But it's still going to be a
big task.


Thomas,

True, but once you have a dataframe with all the information about all the
earthquakes you can extract data for every analysis you want to do.

If you've not read Wes McKinney's "Python for Data Analysis: Data Wrangling
with Pandas, NumPy, and IPython" I encourage you to do so.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Can you process seismographic signals in Python or should I switch to Matlab ?

2023-03-13 Thread Rich Shepard

On Mon, 13 Mar 2023, Thomas Passin wrote:

But what I need is analysis of seismograms from 4,000 seismographs world 
wide to detect P-wave energy distribution underground around the earthquake 
to verify EQ Domino Effect



In that case, you will have to do a great deal of work to get all that
data into a common usable form, cleaned and errors removed. That will be a
lot of effort no matter what language you use. In the Matplotlib lesson
you pointed to, the work was already done, for one one earthquake at one
location.


Wouldn't Pandas help here?

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter module test: widget class not inserted in application frame

2022-06-18 Thread Rich Shepard

On Sat, 18 Jun 2022, Peter J. Holzer wrote:


There is a comma (U+002C) here ...
And a dot (U+002E) here.


That was a typo when I wrote the message. And I usually add a space after
commas and surrounding equal signs, all for easier reading.

Thank you,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter module test: widget class not inserted in application frame

2022-06-17 Thread Rich Shepard

On Fri, 17 Jun 2022, Dennis Lee Bieber wrote:


ContactNameInput, 'lname',
ContactNameInput, 'fname',


This works if a tk.labelframe is where the widget is placed. In my case, as
MRAB taught me, the proper syntax is
self,'lname'...
self.'fname'...

Thanks, Dennis,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter module test: widget class not inserted in application frame

2022-06-17 Thread Rich Shepard

On Fri, 17 Jun 2022, MRAB wrote:


This:

self.inputs['Last name'] = cc.LabelInput(
ContactNameInput, 'lname',
input_class = ttk.Entry,
input_var = tk.StringVar()
)

should be this:

self.inputs['Last name'] = cc.LabelInput(
self, 'lname',
input_class = ttk.Entry,
input_var = tk.StringVar()
)

Also, this:

self.inputs['First name'] = cc.LabelInput(
ContactNameInput, 'fname',
input_class = ttk.Entry,
input_var = tk.StringVar()
)

should be this:

self.inputs['First name'] = cc.LabelInput(
self, 'fname',
input_class = ttk.Entry,
input_var = tk.StringVar()
)


MRAB,

Ah! I must have misread Alan Moore's examples, then. I'll need to fix all my
views.

Thank you,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter module test: widget class not inserted in application frame

2022-06-17 Thread Rich Shepard

On Fri, 17 Jun 2022, MRAB wrote:

You haven't shown the code for common_classes.LabelInput, but I'm guessing 
that the first argument should be the parent.


Here's the LabelInput class:
class LabelInput(tk.Frame):
""" A widget containing a label and input together. """

def __init__(self, parent, label='', input_class=ttk.Entry,
 input_var=None, input_args=None, label_args=None,
 **kwargs):
super().__init__(parent, **kwargs)
label_args = label_args or {}
input_args = input_args or {}
self.variable = input_var,

if input_class in (ttk.Checkbutton, ttk.Button, ttk.Radiobutton):
input_args["text"] = label
input_args["variable"] = input_var
else:
self.label = ttk.Label(self, text=label, **label_args)
self.label.grid(row=0, column=0, sticky=(tk.W + tk.E))
input_args["textvariable"] = input_var

self.input = input_class(self, **input_args)
self.input.grid(row=1, column=0, sticky=(tk.W + tk.E))
self.columnconfigure(0, weight=1)
self.error = getattr(self.input, 'error', tk.StringVar())
self.error_label = ttk.Label(self, textvariable=self.error)
self.error_label.grid(row=2, column=0, sticky=(tk.W + tk.E))

def grid(self, sticky=(tk.E + tk.W), **kwargs):
super().grid(sticky=sticky, **kwargs)

def get(self):
try:
if self.variable:
return self.variable.get()
elif type(self.input) == tk.Text:
return self.input.get('1.0', tk.END)
else:
return self.input.get()
except (TypeError, tk.TclError):
# happens when numeric fields are empty.
return ''

def set(self, value, *args, **kwargs):
if type(self.variable) == tk.BooleanVar:
self.variable.set(bool(value))
elif self.variable:
self.variable.set(value, *args, **kwargs)
elif type(self.input) in (ttk.Checkbutton, ttk.Radiobutton):
if value:
self.input.select()
else:
self.input.deselect()
elif type(self.input) == tk.Text:
self.input.delete('1.0', tk.END)
self.input.insert('1.0', value)
else:
self.input.delete(0, tk.END)
self.input.insert(0, value)

You're passing in the _class_ ConactNameInput, but I'm guessing that it 
should be an _instance_ of that class, in this case, 'self'.


Haven't I done this in the application class?
class NameApplication(tk.Tk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.title("Contact Name")
self.geometry("800x600")
self.resizable(width = False, height = False)
ContactNameInput(self).grid(row = 0, column = 0, sticky=('EWNS'))
self.columnconfigure(0, weight=1)

If not, where do I specify the instance of the ContactNameInput class?

Thanks,

Rich


--
Richard Shepard, Ph.D.  The Environmental Issues Doctor
Applied Ecosystem Services, LLC
Troutdale, OR 97060 USA503-667-4517 www[dot]appl-ecosys[dot]com
--
https://mail.python.org/mailman/listinfo/python-list


Tkinter module test: widget class not inserted in application frame

2022-06-17 Thread Rich Shepard

I'm not seeing the error source in a small tkinter module I'm testing.

The module code:
---
import tkinter as tk
from tkinter import ttk

import common_classes as cc

class ConactNameInput(tk.Frame):
def __init__(self, parent, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
# A dict to keep track of input widgets
self.inputs = {}

self.inputs['Last name'] = cc.LabelInput(
ContactNameInput, 'lname',
input_class = ttk.Entry,
input_var = tk.StringVar()
)
self.inputs['Last name'].grid(row = 0, column = 0)
#
self.inputs['First name'] = cc.LabelInput(
ContactNameInput, 'fname',
input_class = ttk.Entry,
input_var = tk.StringVar()
)
self.inputs['First name'].grid(row = 0, column = 1)

okay_button = tk.Button(self, text="OK",
command=self.ok)
okay_button.pack(side=tk.LEFT, padx=(20, 0), pady=(0, 20))

cancel_button = tk.Button(self, text="Cancel",
  command=self.cancel)
cancel_button.pack(side=tk.RIGHT, padx=(0, 20), pady=(0, 20))

def okay_button(self):
pass

def cancel_button(self):
Quitter()

def get_last_name(self):
pass

def get_first_name(self):
pass


class NameApplication(tk.Tk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.title("Contact Name")
self.geometry("800x600")
self.resizable(width = False, height = False)
ContactNameInput(self).grid(row = 0, column = 0, sticky=('EWNS'))
self.columnconfigure(0, weight=1)

if __name__ == '__main__':
app = NameApplication()
app.mainloop()
--

The python error traceback:
--
Traceback (most recent call last):
  File "contact_history_name_input.py", line 60, in 
app = NameApplication()
  File "contact_history_name_input.py", line 55, in __init__
ContactNameInput(self).grid(row = 0, column = 0, sticky=('EWNS'))
  File "contact_history_name_input.py", line 17, in __init__
input_var = tk.StringVar()
  File "/home/rshepard/development/BusinessTracker/views/common_classes.py", 
line 46, in __init__
super().__init__(parent, **kwargs)
  File "/usr/lib64/python3.7/tkinter/__init__.py", line 2744, in __init__
Widget.__init__(self, master, 'frame', cnf, {}, extra)
  File "/usr/lib64/python3.7/tkinter/__init__.py", line 2292, in __init__
BaseWidget._setup(self, master, cnf)
  File "/usr/lib64/python3.7/tkinter/__init__.py", line 2262, in _setup
self.tk = master.tk
AttributeError: type object 'ContactNameInput' has no attribute 'tk'
--

I'm not correctly placing the NameInput class in the NameApplication frame.
What have I missed?

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter: multicolumn table widget

2022-06-06 Thread Rich Shepard

On Tue, 31 May 2022, MRAB wrote:


There's an example of how to show a tooltip here:
https://stackoverflow.com/questions/3221956/how-do-i-display-tooltips-in-tkinter


MRAB,

A tooltip would work. I downloaded the first example and assume that it will
display a treeview cell when the cursor hovers over it without needing to be
limited to a single column.

When I test the module (I'm still writing it) I'll learn what needs fixing.

Thanks very much,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter: multicolumn table widget

2022-05-31 Thread Rich Shepard

On Tue, 31 May 2022, MRAB wrote:


The note could be displayed partially in the column itself, with the full
text displayed either in read-only textbox nearby when the row is selected
(and it's the only selected row), or in the form of a tooltip when you
hover over it.

There's an example of how to show a tooltip here:
https://stackoverflow.com/questions/3221956/how-do-i-display-tooltips-in-tkinter


MRAB,

Thank you very much. I've been reading about the TreeView and learning how
to use it. Displaying the text column in a read-only textbox or tooltip
would certainly do the job.

Best regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter: multicolumn table widget

2022-05-31 Thread Rich Shepard

On Tue, 31 May 2022, MRAB wrote:


Have a look at the tkinter.ttk.Treeview widget; it can be formatted as a
tree hierarchy, its name suggests, or a multi-column tables, but it
doesn't support multi-line text though, as far as I know.


MRAB,

Thank you, I will.

Each time I add a row to the contacts database table I include a note of
what was discussed and what needs to be done. I'd like to be able to see the
entire note with each contact event.

I'm not committed to using a table so I'm totally open to other approaches.
My needs are few:
  - The returned results are read-only.
  - The number of rows returned are variable.
  - Each row has a contact date, contact type, note, and next contact date.
The last one isn't necessary to be displayed, but the first three are.
  - I want to be able to scroll and view all returned rows.

As with the tkinter.Text widget, you'll need to add the scrollbar(s) 
separately and then link them.


This I expected.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Tkinter: multicolumn table widget

2022-05-31 Thread Rich Shepard

My web searches haven't helped me learn how to design a read-only scrollable
table widget displaying rows retrieved from postgres database tables. This
is for my business development application.

I'm writing a view module that displays my contact history with a named
person. The person's last and first name are passed to the database tables
and all the results are displayed in a read-only view.

The view has three vertical sections: person information on top, contact
methods (phones, email) below that, and a scrollable, multicolumn table
at the bottom.

The table columns consist of three tk.StringVal() and one tk.Text() which
usually has multiple rows related to that contact event.

I want to learn how to create the table so each row has the contents of each
of the four columns and I can scroll down and up to look at the history.

All help is certainly appreciated.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Unable to open Python

2022-03-28 Thread Rich Shepard

On Mon, 28 Mar 2022, kristine RABIA wrote:


I downloaded successfully Python, however when I am trying to open it,
brings the window repair, modify or uninstall, I tried to click on repair
and modify after all it came with the same window. Please advise the
further step.


Kristine,

What operating system do you use?

Python is a programming language, not an application. It is not 'opened' but
used to do a particular job. You use the language to tell the computer what
to do.

What do you want to do with Python?

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter widgets for desktop database application

2021-07-14 Thread Rich Shepard

On Wed, 14 Jul 2021, Betty Hollinshead wrote:


So.I've had success with GTK3 (not Tkinter).


Betty,

There are multiple widget sets and all will work better with some
application types than others.

In the past I used wxPython but switched to Tkinter. Tried PyQt5 (doesn't do
complex, multi-table queries like it does single table queries) and
seriously considered GTK3. After all that time and effort I decided to stick
with tkinter for two reasons: 1) I know it better than PyQt5 and 2) most
users of one application I'm developing run Microsoft's OSes, some Apple.
Since Tkinter comes with Python3 it's one less thing for non-techical users
to struggle with if they decide to use this application.

Thanks for your suggestion,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Tkinter widgets for desktop database application

2021-07-13 Thread Rich Shepard

I'm writing a couple of database applications that use tkinter, and not a
web browser, for the UI and I'm still trying to determine the optimal way to
do this.

Individual tk and ttk widgets (LineEntry, Combobox, etc.) work for adding
and modifying individual database table rows but not for displaying multiple
rows returned by a SELECT statement. To view all rows returned by the SQL
statement would a pythonReport be used?

I'm working on learning to use tksheet as the sole widget because it can
display multiple rows from a database table as well as add new rows and
modify existing ones (one or more columns in each row).

What have other developers used for the UI on a stand-alone database
application not using a web browser? I've struggled with finding the most
efficient and optimal non-brower UI for months and would like to have a
solid path toward a working solution. I know too little to make this
decision and want advice, suggestions, and recommendations from experienced
developers.

TIA,

Rich

--
https://mail.python.org/mailman/listinfo/python-list


Re: Faker package [RESOLVED]

2021-06-19 Thread Rich Shepard

On Sat, 19 Jun 2021, MRAB wrote:


It looks like you're mixing some Python usage ("faker.names()") in with
command line usage.


MRAB,

You are correct. That was my problem.


Judging from the docs, I'd say you need something more like:
   $ faker -o temp.out name
for 1 fake name or:
   $ faker -r=10 -o temp.out name
for 10 fake names.


Thank you. I didn't pick that up when I read the document.

Much appreciated,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Faker package

2021-06-18 Thread Rich Shepard

On Sat, 19 Jun 2021, MRAB wrote:

When it says "command line" it means the operating system's command line. If 
it's the Python shell , it'll say "Python shell" or "Python prompt.


MRAB,

The root shell's (#) what I assumed. User shells (in bash, anyway) have $ as
the prompt.

Regardless,

$ faker -o temp.out faker.names()
-bash: syntax error near unexpected token `('
[rshepard@salmo ~]$ faker -o temp.out faker.names 
Traceback (most recent call last):

  File "/usr/bin/faker", line 8, in 
sys.exit(execute_from_command_line())
  File "/usr/lib64/python3.7/site-packages/faker/cli.py", line 264, in 
execute_from_command_line
command.execute()
  File "/usr/lib64/python3.7/site-packages/faker/cli.py", line 246, in execute
includes=arguments.include,
  File "/usr/lib64/python3.7/site-packages/faker/cli.py", line 67, in print_doc
provider_or_field], includes=includes)
  File "/usr/lib64/python3.7/site-packages/faker/proxy.py", line 63, in __init__
**config)
  File "/usr/lib64/python3.7/site-packages/faker/factory.py", line 56, in create
prov_cls, lang_found = cls._get_provider_class(prov_name, locale)
  File "/usr/lib64/python3.7/site-packages/faker/factory.py", line 68, in 
_get_provider_class
provider_class = cls._find_provider_class(provider, locale)
  File "/usr/lib64/python3.7/site-packages/faker/factory.py", line 90, in 
_find_provider_class
provider_module = import_module(provider_path)
  File "/usr/lib64/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1006, in _gcd_import
  File "", line 983, in _find_and_load
  File "", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'faker.names'
[rshepard@salmo ~]$

It does not work from the bash command line as a user or as root.

The "root shell prompt (#)" suggests to  me that it's Linux, so if you're 
using Windows you'll need to use the equivalent for Windows.


I don't do windows; defenestrated 24 years ago.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Faker package

2021-06-18 Thread Rich Shepard

On Fri, 18 Jun 2021, Terry Reedy wrote:


I would try using the 'given' function/decorator of hypothesis (on pypi)
to generate random data that conforms to whatever specification.


Thank you, Terry. I'll do that.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Faker package

2021-06-18 Thread Rich Shepard

I'm trying to use the faker package to generate data to load in a sample
postgres database so I can learn how to use tksheet and psycopg2.

The 8.8.1 documentation shows output on a root shell prompt (#), not a
python prompt (>>>). It also has a description of using faker from 'the
command line', which I assume is the python shell, and I can't get it to
work. I suppose that I can generate one name, address, etc. at a time and
them copy and concatenate them into table data, but I thought that the faker
package would do this all for me.

Is there a tool that will let me generate the equivalent of a database row
worth of data? That is, a set of strings of different types that can then be
inserted into the testing database?

Rich


--
https://mail.python.org/mailman/listinfo/python-list


Re: tkinter: tksheet

2021-06-17 Thread Rich Shepard

On Thu, 17 Jun 2021, Dennis Lee Bieber wrote:


FreePascal/Lazarus is supposed to be similar to Delphi, and does
have Linux installs -- but I don't know what it provides for database
linkages. I do have it installed on my Windows box (the Linux install is
HUGE; takes up over 1/4 of the space on BeagleBone Black so I didn't
install it there).


Dennis,

In the 1980s I looked closely at Pascal. More recently I did so again
because the local linux/UNIX group had a presentation on its use. Decided
another language was not for me.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: tkinter: tksheet

2021-06-17 Thread Rich Shepard

On Thu, 17 Jun 2021, Alan Gauld via Python-list wrote:


Sounds like a job for a database view. Can you modify the database schema?
Could you create a view - even a temporary one just while your app is
running?


Alan,

Yes, created views work well with postgres. Building one for complex,
multitable queries is always a good idea.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: tkinter: tksheet

2021-06-17 Thread Rich Shepard

On Thu, 17 Jun 2021, Dennis Lee Bieber wrote:


My naive idea is to use two queries, one selects * from the company table
ordered by nunber, the other by name. The UI offers two radiobuttons when
viewing the results, one for each sort column.


Presuming all the data fits in memory, it may be faster to just define
the key structure for Python's internal sort() function than to go back out
to the database server, wait for it to gather the desired fields and sort
them, then transfer all the data back to your script.


Dennis,

That's a possibility.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: tkinter: tksheet

2021-06-16 Thread Rich Shepard

On Wed, 16 Jun 2021, Alan Gauld via Python-list wrote:


But there is nothing I know of for Tkinter that provides views of database
tables in the way that Delphi or VB or C# do, for example.


Alan,

These are all Microsoft tools. I run linux only.


You have to extract the data using SQL and populate the table and manage
all changes (of both view and data) yourself.



From an incomplete reading of the tksheet() doc it looks to be the best way

to display tables returned by a SQL query. PyQt5 has a QTableView() that
does the job, and it works great for a single table, but apparently not so
well with complex joins on multiple tables.

When I view my contacts table it needs to includes attributes from the
company, people, and contacts tables so I can view all prior contacts with
that person.


If you do a lot of that kind of desktop apps then you could look at Dabo
which is built on wxPython but has links to databases. Unfortunately it
looks like work ground to a halt about 5 years ago.


Many years ago I used wxPython. For several reasons I decided to learn and
use tkinter from now one. One reason is that the application for my clients
will run mostly on windows hosts and I want to limit the software they need
to install and maintain in order to run it.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: tkinter: tksheet

2021-06-16 Thread Rich Shepard

On Thu, 17 Jun 2021, dn via Python-list wrote:


Use the DBMS by retrieving the data in the desired sequence?


dn,

Yep. That's what I thought would be the best approach.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: tkinter: tksheet

2021-06-16 Thread Rich Shepard

On Wed, 16 Jun 2021, Dennis Lee Bieber wrote:


Scroll further down to "bindings"... rc_insert_row -- a 
menu binding


Dennis,

Yes, I saw that one, too.


As for sorting, I don't see anything that allows one to add custom
events to the bindings... best I can come up with is that if a header
column is selected you sort the data and reload the table.


My naive idea is to use two queries, one selects * from the company table
ordered by nunber, the other by name. The UI offers two radiobuttons when
viewing the results, one for each sort column.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: tkinter: tksheet

2021-06-16 Thread Rich Shepard

On Wed, 16 Jun 2021, Terry Reedy wrote:


Somewhat sparse doc at
https://github.com/ragardner/tksheet/blob/master/DOCUMENTATION.md#5-modifying-table-data
insert_row()


Terry,

I'm reading this now and saw that.


and change the column used for sorting (e.g.,

sorting by company number or company name).


I did not see anything about sorting.  tksheet is generic 'table', not a 
database viewer


The two applications I'm building are both database applications. If
tksheet() is not the most appropriate widget to display database tables what
alternative would be better?

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


tkinter: tksheet

2021-06-16 Thread Rich Shepard

Reading the doc for tksheet tells me that it allows me to modify cells (or
entire rows) as well as display them. What I don't see is whether I can add
a new row using tksheet and change the column used for sorting (e.g.,
sorting by company number or company name).

If you have experience with tksheet perhaps you can answer my questions
about it's capabilities.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter8.6: date picker

2021-06-11 Thread Rich Shepard

On Fri, 11 Jun 2021, Dan Stromberg wrote:


I think most Python folks are doing their GUI's with a web browser, Qt, or
GTK+. I mostly use GTK+. But best wishes on getting a recommendation for a
Tkinter date picker.


Dan,

I don't like working in a web browser; Qt apparently has very weak support
for multiple-table databases where joins involve several tables, and I've
never used GTK+ for UI.

One of the applications I'm developing will be for my clients to use. Most
of them run some flavor of Windows so I want to keep the software
requirements simple: Python3 and SQLite3.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Tkinter8.6: date picker

2021-06-11 Thread Rich Shepard

I need a date picker for a couple of Python-3.7.2/Tkinter8.6 applications. 
There seem
to be some available on the web. If you have experience with a date picker
(not a calendar that holds appointments for a given date) I'd like your
suggestions and recommendations for one.

TIA,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Recommendation for drawing graphs and creating tables, saving as PDF

2021-06-11 Thread Rich Shepard

On Fri, 11 Jun 2021, Jan Erik Moström wrote:


I looked around around but could only find two types of libraries for a)
libraries for creating histograms, bar charts, etc, b) very basic drawing
tools that requires me to figure out the layout etc. I would prefer a
library that would allow me to state "connect A to B", "connect C to B",
"connect B to D", and the library would do the whole layout.


JEM,

PSTricks 


(and yes, I could obviously use LaTeX ...)


They work well together.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Neither pdb or print() displays the bug [FIXED]

2021-06-08 Thread Rich Shepard

On Tue, 1 Jun 2021, Rich Shepard wrote:


I'm stuck with neither approach (pdb, print()) working. I moved the
database code to a separate module, datasource.py, and when I run the
activitytypes.py module (using pdb and having entered print() statements
at various places in both the datasource and activities modules all I get
is a small, empty window with the window title. The QSize() statement is
never reached.


Found and fixed the problem. Qt5 added support for PostgreSQL-12 in
Qt5-5.15.0. I upgraded both Qt5 and PyQt5 to 5.15.2 and now the tables
display the rows in the one column of the table.

Thanks for all the suggestions,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Posting code on stackoverflow

2021-06-06 Thread Rich Shepard

On Sat, 5 Jun 2021, Terry Reedy wrote:


Last time I tried *before*, it did not work. paste, reselect (a nuisance)
and click does.


Terry,

I had tried that and it didn't work any better. Bounding the code with two
sets of three backticks does work.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Neither pdb or print() displays the bug

2021-06-06 Thread Rich Shepard

On Sun, 6 Jun 2021, Fabio Zadrozny wrote:


Hint: you should be able to use https://pypi.org/project/pytest-qt/ to
unit-test a PyQt application...


Fabio,

Thank you for confirming this. I hadn't remembered the name so your URL is
really helpful.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Posting code on stackoverflow

2021-06-06 Thread Rich Shepard

On Sun, 6 Jun 2021, joseph pareti wrote:


you need to put the code between 2 lines defined as follows:
```
then it will be formatted for you


Thanks, Joseph. I figured that out on the web page.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Posting code on stackoverflow

2021-06-05 Thread Rich Shepard

On Sun, 6 Jun 2021, Roel Schroeven wrote:


There are several ways to format code on StackOverflow, see
https://meta.stackoverflow.com/questions/251361/how-do-i-format-my-code-blocks


Roel,

Thanks very much for the URL.


What I do most of the time is indent the code by 4 spaces and make sure
there are blank lines before and after the code block.


Just now I noticed a link 'code' along the top of the window. Clicking on
that I read that a code block can be identified as such by surrounding it
with sets of three backticks (```). That worked.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Posting code on stackoverflow

2021-06-05 Thread Rich Shepard

I tried to post a question on stackoverflow.com which included a bunch of
code (entered after clicking the box 'code'). I noticed that lines were
wrapped but could not find how to expand the input box so they would not
wrap.

SO wouldn't let me post the question because of the wrapped code. As I've
not asked a question ther for a long time, and it didn't involve long lines
of code, I need to learn a) how to enter code if it's not just clicking on
the 'code' box before pasting text and b) how to keep code lines from
wrapping so a horizontal scroll bar is made available.

TIA,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Neither pdb or print() displays the bug

2021-06-02 Thread Rich Shepard

On Wed, 2 Jun 2021, Peter Otten wrote:


Do you have unit tests? Those are an excellent tool to ensure that the
components of an application work as expected and that those components
have well-defined interfaces. Debugging a failing unittest is usually
easier than to debug a complex application. While I don't know if there is
a convenient way to test the GUI everything else should run reliably
*before* connecting it with the GUI.


Peter,

I believe there is a way to apply unit tests to PyQt and I'll certainly
learn to take this testing-while-developing approach.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Neither pdb or print() displays the bug

2021-06-01 Thread Rich Shepard

On Tue, 1 Jun 2021, Dennis Lee Bieber wrote:


I suspect you really should be stepping INTO the calls, not just
invoking the functions completely and going to the next LOCAL statement.



$ /development/business_tracker/activitytypes.py(1)()

-> import sys
(Pdb) s

$ /development/business_tracker/activitytypes.py(2)()

-> import logging
(Pdb) s
--Call--

(978)_find_and_load()

(Pdb) s

Now I'll go learn what this means.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Neither pdb or print() displays the bug

2021-06-01 Thread Rich Shepard

On Tue, 1 Jun 2021, Ethan Furman wrote:


Well, you only had two logging statements in that code -- logging is like
print: if you want to see it, you have to call it:


Ethan,

Got it, thanks.

I believe my problem is with the datasource module. I'm focused on making it
work (using logging to confirm that it is doing so). Will report results
when they're available.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Neither pdb or print() displays the bug

2021-06-01 Thread Rich Shepard

On Tue, 1 Jun 2021, Ethan Furman wrote:


Sounds like a console issue. Try using `logging` with a file... you could
even use `print` with a file if you wanted to.


Ethan,

Not before using logging I found a reference/example page

and modified the module to this:

# activitytypes.py
import sys
import logging

from PyQt5 import QtWidgets as qtw
from PyQt5 import QtGui as qtg
from PyQt5 import QtCore as qtc
from PyQt5 import QtSql as qts

from datasource import db

logging.basicConfig(level=logging.DEBUG, format='%(asctime)s -%(levelname)s - 
%(message)s')
logging.debug("Start of Program")

class ATMainWindow(qtw.QMainWindow):

def __init__(self):
super().__init__()

# Model/View here.
self.model = qts.QSqlTableModel(db=db) # for single table
self.model.setTable('activitytypes')
self.model.select()

self.table = qtw.QTableView()
self.table.setModel(self.model)

self.setMinimumSize(qtc.QSize(800, 600))
self.setCentralWidget(self.table)


if __name__ == '__main__':
app = qtw.QApplication(sys.argv)
window = ATMainWindow()
window.show()
#sys.exit(app.exec())
app.exec_()

logging.debug("End of Program")

When I run it this is the output:
$ python activitytypes.py 
2021-06-01 13:39:10,219 -DEBUG - Start of Program

2021-06-01 13:39:15,229 -DEBUG - End of Program

Obviously I have much to learn about using python's logging capabilities.
I'll keep looking.

Thanks,

Rich




--
https://mail.python.org/mailman/listinfo/python-list


Re: Neither pdb or print() displays the bug

2021-06-01 Thread Rich Shepard

On Tue, 1 Jun 2021, Rich Shepard wrote:


The QSize() statement is never reached.


Correction: the window is 800 x 600, but it's still empty.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Neither pdb or print() displays the bug

2021-06-01 Thread Rich Shepard

On Sun, 30 May 2021, Cameron Simpson wrote:


I've only just started with pdb. As of Python 3.7 there's a builtin
function named breakpoint() which drops you into the debugger. I've never
been a big debugger person, historicly using print() and equivalent.
However, this makes it very easy to insert this call into a piece of code
instead of having to invoke one's programme in a special way.


I'm stuck with neither approach (pdb, print()) working. I moved the database
code to a separate module, datasource.py, and when I run the
activitytypes.py module (using pdb and having entered print() statements at
various places in both the datasource and activities modules all I get is a
small, empty window with the window title. The QSize() statement is never
reached.

The activitytypes.py module:

import sys
from PyQt5 import QtWidgets as qtw
from PyQt5 import QtGui as qtg
from PyQt5 import QtCore as qtc
from PyQt5 import QtSql as qts

from datasource import db

class ATMainWindow(qtw.QMainWindow):

def __init__(self):
super().__init__()

# Model/View here.
self.model = qts.QSqlTableModel(db=db) # for single table
self.model.setTable('activitytypes')
self.model.select()

self.table = qtw.QTableView()
self.table.setModel(self.model)

self.setFixedSize(qtc.QSize(800, 600))
self.setCentralWidget(self.table)


if __name__ == '__main__':
app = qtw.QApplication(sys.argv)
window = ATMainWindow()
window.show()
#sys.exit(app.exec())
app.exec_()

Running the module in pdb and using 'next' to step through it produces this
result:


$/development/business_tracker/activitytypes.py(29)()

-> window = ATMainWindow()
(Pdb) n
False

$/development/business_tracker/activitytypes.py(30)()

-> window.show()
(Pdb) n

$/development/business_tracker/activitytypes.py(32)()

-> app.exec_()
(Pdb) n
n

$/development/business_tracker/activitytypes.py(32)()->None

-> app.exec_()
(Pdb) n

and there it sits. No (Pdb) prompt, nothing. And no printed statements.

I'd appreciate recommendations on the process to find where the bug lives
since I can't seem to find it with print() or line-by-line in pdb.

TIA,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Applying winpdb_reborn

2021-05-29 Thread Rich Shepard

On Sun, 30 May 2021, Chris Angelico wrote:


(Plus, there's not always an opportunity to use a debug harness. Sometimes
you just have to put your prints into production and let it run for two
weeks in the hope that the bug will show itself.)


ChrisA,

Please excuse my long-winded description of a FORTRAN IV bug in an lake
ecosystem energy model I wrote at the University of Illinois in the early
1970s. It is an example of what you wrote above.

The program fill two boxes of 80-column Hollerith cards punched on an IBM
29 (if I correctly recall the model) keypuch machine. The output was written
on green-barred wide paper on a line printer.

Each time I ran the model it would produce one of four different, but wrong,
answers for one variable. I closely examined the 1.5" thick fan-folded line
printer output many times. I never saw the error, even with diagnostic stubs
added. When I took the output to the computer center they looked at it for a
week and couldn't find the error, either.

Shortly after that, when I again examined the code, line-by-line, I saw the
error: a line that should have read
FOR I=1 to N
actually read
FOR I=I to N

All of us saw the uppercase I as a 1 because a) that's what we expected to
see and b) line printer output on green-barred paper was not that clear,
even with fresh ribbons.

That lesson has stuck with me ever since.

Regards,

Rich

--
https://mail.python.org/mailman/listinfo/python-list


Re: Applying winpdb_reborn

2021-05-29 Thread Rich Shepard

On Sun, 30 May 2021, Cameron Simpson wrote:


Also, searching for "pdb tutorial" seems to find a bunch of links.


Cameron,

That's true. All the ones I've read list the various pdb commands. Knowing
the commands is different from knowing when and how to apply them.

I'll work back to remembering how I debugged code years ago with stubs and
print() statements and use pdb with them.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Applying winpdb_reborn

2021-05-29 Thread Rich Shepard

On Sat, 29 May 2021, Dennis Lee Bieber wrote:


Except the copy of winpdb source I looked at has

RPDBTERM = 'RPDBTERM'

near the top.

Then again, I don't know how up-to-date the OP's copy is -- I just
Googled for a repository with the module.

Let me check a Linux environment (Debian 10 VM) (Great -- I attempted
to use the default password of a Beaglebone Black )


I've removed winpdb here as recommended by Philippe Fremy. I don't use IDEs
other than emacs so I'll stick with pdb.

What I find interesting is that every web page I find on 'using pdb' does no
more than explain the available commands; they don't explain the debugging
process. That's like showing someone what the word processor menus do; it
doesn't teach the user how to be a writer.

I knew the debugging process with Fortran and C, but haven't learned how to
effectively use pdb to find bugs that don't issue a traceback or obvious
wrong answer such as my module displaying an empty window with no widgets.

Rich

--
https://mail.python.org/mailman/listinfo/python-list


Re: Applying winpdb_reborn

2021-05-28 Thread Rich Shepard

On Fri, 28 May 2021, Dennis Lee Bieber wrote:


It's apparently looking for some environment variable based upon the
code at
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwjfpYmk3-zwAhULI6wKHSPjAFIQFnoECAUQAA&url=http%3A%2F%2Fphault.rhul.ac.uk%2Fpy%2F_spe%2Fplugins%2Fwinpdb%2Frpdb2.py&usg=AOvVaw12BuzlEMVXrEuOFLoQLpFX


Thanks, Dennis. It looked like an environment variable but I hadn't seen
that with the python2 winpdb.

I'll add that to ~/.bash_profile and see what happens.

Enjoy the holiday weekend,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Applying winpdb_reborn

2021-05-28 Thread Rich Shepard

On Fri, 28 May 2021, MRAB wrote:


Have you looked at the package's repository?


MRAB,


It looks like this is the one:
https://github.com/bluebird75/winpdb


That's where I got it.

Thanks,

Rich

--
https://mail.python.org/mailman/listinfo/python-list


RE: Applying winpdb_reborn

2021-05-28 Thread Rich Shepard

On Fri, 28 May 2021, Schachner, Joseph wrote:


I have no familiarity with this issue, but I think one thing to check is
whether all capitalized RPDBTERM is truly the name you are looking for,
remember that Python is case sensitive.


Joseph,

According to the only doc I could find,
"RPDB2 startup:
Say you have a script x.py to debug, with command-lin
arguments arg0, arg1 etc. Then to start RPDB2, type
python rpdb2.py x.py arg0 arg1 ..."

I don't know of any linux utility whose name is in all uppercase letters.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Applying winpdb_reborn

2021-05-28 Thread Rich Shepard

I'm trying to debug a module of a PyQt5 application using winpdb_reborn.
When I invoke the debugger with the module's name I get an empty winpdb
window and the console tells me that it cannot find RPDBTERM. The full
traceback is attached.

Here, rpdb2 is available:
$ locate rpdb2.py
/usr/lib64/python3.7/site-packages/rpdb2.py
/opt/winpdb-master/build/lib/rpdb2.py
/opt/winpdb-master/rpdb2.py

My only reference to winpdb_reborn is "Norm Matloff's Introduction to the
Winpdb Python Debugging Tool (not just for Windows!)" and the text does not
contain anything about RPDBTERM.

I need advice on debuggng this module (when run only an empty window is
displayed) and using winpdb_reborn.

TIA,

Rich
$ winpdb activitytype.py 
08:20:06.052 rpdb2.py:6148 MainThread/140081468266240 __setrecursionlimit(): rl 
= 1000
08:20:06.348 winpdb.py:3006 MainThread/140081468266240 set_font(): Using font 
"Monospace" for Console
08:20:06.350 winpdb.py:3006 MainThread/140081468266240 set_font(): Using font 
"Monospace" for Console

(winpdb:5519): Gtk-CRITICAL **: gtk_widget_get_preferred_width_for_height: 
assertion 'height >= 0' failed

(winpdb:5519): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate 
widget with width 13 and height -22

(winpdb:5519): Gtk-CRITICAL **: gtk_widget_get_preferred_width_for_height: 
assertion 'height >= 0' failed

(winpdb:5519): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate 
widget with width 13 and height -22

(winpdb:5519): Gtk-CRITICAL **: gtk_widget_get_preferred_width_for_height: 
assertion 'height >= 0' failed

(winpdb:5519): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate 
widget with width 13 and height -22
*** BUG ***
In pixman_region32_init_rect: Invalid rectangle passed
Set a breakpoint on '_pixman_log_error' to debug

Traceback (most recent call last):
  File "/usr/lib64/python3.7/site-packages/winpdb.py", line 1288, in __wrapper
self.m_f(*args, **kwargs)
  File "/usr/lib64/python3.7/site-packages/rpdb/session_manager.py", line 197, 
in launch
return self.__smi.launch(fchdir, command_line, interpreter, 
fload_breakpoints)
  File "/usr/lib64/python3.7/site-packages/rpdb/session_manager.py", line 1160, 
in launch
self._spawn_server(fchdir, ExpandedFilename, args, rid, interpreter)
  File "/usr/lib64/python3.7/site-packages/rpdb/session_manager.py", line 1269, 
in _spawn_server
terminal_command = CalcTerminalCommand()
  File "/usr/lib64/python3.7/site-packages/rpdb/session_manager.py", line 2385, 
in CalcTerminalCommand
if RPDBTERM in os.environ:
NameError: name 'RPDBTERM' is not defined
Traceback (most recent call last):
  File "/usr/lib64/python3.7/site-packages/winpdb.py", line 1288, in __wrapper
self.m_f(*args, **kwargs)
  File "/usr/lib64/python3.7/site-packages/rpdb/session_manager.py", line 197, 
in launch
return self.__smi.launch(fchdir, command_line, interpreter, 
fload_breakpoints)
  File "/usr/lib64/python3.7/site-packages/rpdb/session_manager.py", line 1160, 
in launch
self._spawn_server(fchdir, ExpandedFilename, args, rid, interpreter)
  File "/usr/lib64/python3.7/site-packages/rpdb/session_manager.py", line 1269, 
in _spawn_server
terminal_command = CalcTerminalCommand()
  File "/usr/lib64/python3.7/site-packages/rpdb/session_manager.py", line 2385, 
in CalcTerminalCommand
if RPDBTERM in os.environ:
NameError: name 'RPDBTERM' is not defined
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ad-hoc SQL query builder for Python3?

2021-04-27 Thread Rich Shepard

On Mon, 27 Apr 2021, Robert Latest via Python-list wrote:


In case nobody mentioned it before, don't forget to take a look at
SQLAlchemy. The object-relational-mapper (ORM) creates a 1:1 mapping of
Python objects to SQL table rows.


Robert,

Yes, I've known of SA for years. I want something that can be embedded in
the application so the user doesn't need to install another dependentcy
package and maintain it.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Ad-hoc SQL query builder for Python3?

2021-04-26 Thread Rich Shepard

On Sat, 24 Apr 2021, Rich Shepard wrote:


My web searches are not finding what I need to include in an application I'm
building: an ad-hoc sql query builder.


For those interested I've found a couple of possibilities: PyPika and
SQLbuilder. I'll be looking deeply into them to learn their capabilities.

My model is the query-by-example (QBE) used in Paradox for DOS in the 1980s
and 1990s.

Thanks for all your comments,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Ad-hoc SQL query builder for Python3?

2021-04-25 Thread Rich Shepard

On Sun, 25 Apr 2021, Peter J. Holzer wrote:


What should that sql query builder build the queries from? Or in other
words what is the user supposed to input?


Peter,


From the dialog box offering tables, columns, and rows from which a SELECT

statement will be constructed.

This is not a console application with a CLI; it has a GUI so there's no
direct access to the backend db from within the application.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Ad-hoc SQL query builder for Python3?

2021-04-25 Thread Rich Shepard

On Sun, 25 Apr 2021, Alan Gauld via Python-list wrote:


I assume you understand the huge risks involved in such a tool. Letting
users loose on their own data (and possibly other peoples) allows for huge
potential damage/data loss etc.


Alan,

I disagree about the risk. Regardless of the form of the Select statement it
does not delete any rows. Users will be able to specify attributes (columns)
and instances (rows) but not delete or update any table.


You can reduce the risk by finding ways to limit the access to read-only
and tightly controlling which tables etc can be accessed.



But many SQL builder tools don't do that and simply provide a way to
create queries, including drop table, delete from etc. (Quite reasonably
since they are usually aimed at DBAs rather than ordinary users)


That's if the inclusion of the tool allows it.

Of course, if the user knows SQL they could do what they want directly on
the database ignoring the application entirely. If they knew enough to do
this they would be using a database rather than a spreadsheet in the first
place. :-)

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Ad-hoc SQL query builder for Python3?

2021-04-24 Thread Rich Shepard

On Sat, 24 Apr 2021, J. Pic wrote:


Maybe search or ask dba stackexchange for more, meanwhile, here's a
popular one: https://github.com/dbeaver/dbeaver


J.,

I use dbeaver-ce now and then as an admin tool. I didn't consider it as an
included component in a desktop application. I'll look at it from that
perspective.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Ad-hoc SQL query builder for Python3?

2021-04-24 Thread Rich Shepard

My web searches are not finding what I need to include in an application I'm
building: an ad-hoc sql query builder.

End users will want to query their data for reports not included in the
built-in queries. My searches find a windows-only tool that apparently costs
developers for the version to include in their applications. I'm looking for
a F/OSS tool and I'm sure these are available somewhere.

Suggestions are needed.

TIA,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Ann: New Python curses book

2021-04-15 Thread Rich Shepard

On Thu, 15 Apr 2021, Alan Gauld via Python-list wrote:


In the main() function the block of code starting with the 'with'
statement should be indented to be part of main(). It has been left at the
outermost indentation level.

The source code file is correct so check against that.


Thanks, Alan.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Ann: New Python curses book

2021-04-14 Thread Rich Shepard

On Wed, 14 Apr 2021, Alan Gauld via Python-list wrote:


The paper version should be fine (apart from one error on p44 which has
now been fixed!).


Alan,

What's the error and correction so I can change it in my dead tree version?

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: UI design: combobox or radiobuttons?

2021-04-13 Thread Rich Shepard

On Wed, 14 Apr 2021, Alan Gauld via Python-list wrote:


readability? If the combo box puts the units immediately beside the value
then it will be more readable than if it is a row of radio buttons
above/below or beside the value.

But if the radio buttons represent a unit choice that applies to all
values on the screen then that is more noticeable and thus more readable
than a single small combobox choice lurking in a corner somewhere.


Excellent points, Alan.

Thanks very much,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


UI design: combobox or radiobuttons?

2021-04-13 Thread Rich Shepard

My applications use environmental data, each of which has to specify the
units (e.g., cm, m, km, ft, yd, mi). With the widget sets I've used
(wxPython and TKinter) I've always used a combobox with the acceptable
choices in it. I'm now planning a new application using PyQt5 and it occured
to me that a set of radio buttons would also work.

While a set of radiobuttons occupies more room on the parent widget than
does a combobox are there any technical or user issues that would suggest
using one over the other?

TIA,

Rich

--
https://mail.python.org/mailman/listinfo/python-list


Re: Comparing text strings

2021-04-13 Thread Rich Shepard

On Tue, 13 Apr 2021, jak wrote:


If I understand your problem correctly, the problem would be dealing with
numbers as such in file names. This is just a track but it might help you.
This example splits filenames into strings and numbers into tuples,
appends the tuple into a list, and then sorts the list:


jak,

Yes, it would be the version and build numbers that differ when two files
have the same initial string (application name).

Thanks very much,

Rich


--
https://mail.python.org/mailman/listinfo/python-list


Re: Comparing text strings

2021-04-13 Thread Rich Shepard

On Tue, 13 Apr 2021, Cameron Simpson wrote:


The problem is not that simple. Sometimes the package maintainer upgrades
the package for the same version number so there could be abc-1.0_1_SBo.tgz
and abc-1.0_2_SBo.tgz. The more involved route will be taken.


If that _1, _2 thing is like RedHat's -1, -2 suffixes for later releases
of the same source package version, you could just include that in the
version string. Looks like it counts up.


Cameron,

There are two variables: the application/tool version number and the build
number. They're both embedded within the filename string. I don't know in
advance the build numbers if it's that variable that's changed.

The list of installed files is (currently) less than 500 lines so a
character-by-character comparison when two rows begin with the same string
will not take long.

Thanks again,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Comparing text strings

2021-04-12 Thread Rich Shepard

On Tue, 13 Apr 2021, Cameron Simpson wrote:


I do not know if there are preexisting modules/tools for this, but I
recommend looking at slackware's package management tool - they usually
have some kind of 'clean" operation to purge "old" package install files.
Sometimes that purges all the install files, not just the obsolete ones,
so take care.


Cameron,

slackpkg clean removes all non-core distribution files. That's how I FUBAR'd
my system a couple of months ago.


If you're writing a script, what you want to do is read the names and
extract the version information from them, and also the "package name" -
the bit which identifies the package and does not change with an upgrade.


Yes, that's the approach I would take.


I would then make a dict mapping package names to a list of versions
and/or the full "...tgz" names above. (Actually, use a
defaultdict(list), it will avoid a lot of tedious mucking about.)


Okay. That didn't occur to me.


Alternatively, and now that I think about it, more simply: _if_ the
package files can be sorted by version, then all you need to do is read a
sorted listing and note that latest fil for a particular package. If you
need another one, it should be newer and you can remove the "known"
package file, and update your record that to the new one.


The problem is not that simple. Sometimes the package maintainer upgrades
the package for the same version number so there could be abc-1.0_1_SBo.tgz
and abc-1.0_2_SBo.tgz. The more involved route will be taken.

Thanks!

Rich


--
https://mail.python.org/mailman/listinfo/python-list


Comparing text strings

2021-04-12 Thread Rich Shepard

I'm running Slackware64-14.2 and keep a list of installed packages. When a
package is upgraded I want to remove the earlier version, and I've not
before written a script like this. Could there be a module or tool that
already exists to do this? If not, which string function would be best
suited to the task?

Here's an example:
atftp-0.7.2-x86_64-2_SBo.tgz
atftp-0.7.4-x86_64-1_SBo.tgz

and there are others like this. I want the python3 script to remove the
first one. Tools like like 'find' or 'sort -u' won't work because while the
file name is the same the version or build numbers differ.

All suggestions welcome.

Rich

--
https://mail.python.org/mailman/listinfo/python-list


Re: editor recommendations?

2021-02-26 Thread Rich Shepard

On Fri, 26 Feb 2021, 2qdxy4rzwzuui...@potatochowder.com wrote:


That's what my emacs looks like, minus the light-grey frame (the window
manager's frame and border are enough for me). Emacs has themes now, but
my setup is very old; all I did was set the "base" text background and
foreground colors and set a flag that says "I have a dark background
rather than a light one."


Emacs: +1. I've been using it for more than two decades. It will provide
syntax coloring (on the black background) for Python as well as other
languages and file types.


Did you have a Python question?  ;-)


Perhaps he didn't but he should know that by opening a shell within emacs he
can run his python code there.

Long ago someone wrote that Emacs is an operating system that includes the
kitchen sink. A friend of mine working for Sharp Electronics did all his
work in Emacs, including email and web browsing (back when a text-based
browser was sufficient.)

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Writing a Python3 ttk.Notebook

2021-01-15 Thread Rich Shepard

On Fri, 15 Jan 2021, Terry Reedy wrote:


IDLE's settings dialog uses a ttk.Notebook. The file is
Lib/idlelib/configdialog.py.


Thanks, Terry! I completely forgot that. I'll study the IDLE's code and
learn from that.

Stay well,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Writing a Python3 ttk.Notebook

2021-01-15 Thread Rich Shepard

On Fri, 15 Jan 2021, Rich Shepard wrote:


Progress: I didn't put the notebook on the main window using grid. Now I
need to find how to specify the position so it's at the top of the window.
I'll read the options on grid.


The notebook tabs are placed on the grid as nb.grid(row=0, column=0,
columnspan=6). But, it's in the center of the main frame and small.

All the references I've found in Tkinter books and on the web have small,
stand-alone, samples of notebooks. Is
<https://www.tcl.tk/man/tcl8.5/TkCmd/ttk_notebook.htm> the best and most
complete reference for learning how to apply a ttk.Notebook?

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Writing a Python3 ttk.Notebook

2021-01-15 Thread Rich Shepard

On Fri, 15 Jan 2021, Rich Shepard wrote:


The file 'application.py' is attached. If I had better docs here I could
probably work a lot of this out by myself.


Progress: I didn't put the notebook on the main window using grid. Now I
need to find how to specify the position so it's at the top of the window.
I'll read the options on grid.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Writing a Python3 ttk.Notebook

2021-01-15 Thread Rich Shepard

On Fri, 15 Jan 2021, Dennis Lee Bieber wrote:


Off-hand, I'd suspect you should be adding these to the NOTEBOOK
object "n".


Dennis,

You're correct. The MWE didn't have the proper syntax.

Now, the problem is the notebook doesn't display its tabs on the main
window, while the proper syntax on a separate file opens a window with the
tabs displayed.

The file 'application.py' is attached. If I had better docs here I could
probably work a lot of this out by myself.

Regards,

Rich
#!/usr/bin/env python3

# main file to start application.

from os import environ
import sys
from datetime import datetime
import tkinter as tk
from tkinter import ttk
from tkinter.ttk import Notebook as nb
from tkinter import filedialog
from tkinter import messagebox
from tkinter.font import nametofont
from functools import partial
import model as m
import views as v
import controller as c


class Application(tk.Tk):
""" Application root window """

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# the top level frame holding notebook, status bar, etc.
self.columnconfigure(0, weight=1)   # helps with frame/app resizing on 
the fly
self.rowconfigure(0, weight=1)  # helps with frame/app resizing on 
the fly
# open application centered on screen; set window width and height
self.appwidth = 1000
self.appheight = 800
# get screen width and height
self.scrwidth = self.winfo_screenwidth()
self.scrheight = self.winfo_screenheight()
# formula to find screen center
self.xLeft = (self.scrwidth/2) - (self.appwidth/2)
self.yTop = (self.scrheight/2) - (self.appheight/2)
# set geometry
self.geometry(str(self.appwidth) + "x" + str(self.appheight) +
  "+" + str(int(self.xLeft)) + "+" + str(int(self.yTop)))

self.title("Main Window Title Goes Here")
self.resizable(width=True, height=True)

datestring = datetime.today().strftime("%Y-%m-%d")

# variables for adjusting font size and style
self.font_bold = tk.BooleanVar()
self.font_size = tk.IntVar()

def set_font(*args):
self.font_spec = 'TkDefaultFont {size} {bold}'.format(
size=font_size.get(),
bold='bold' if font_bold.get() else '')
self.label.config(font=font_spec)
self.font_bold.trace('w', set_font)
self.font_size.trace('w', set_font)

# status bar
self.status = tk.StringVar()
self.statusbar = ttk.Label(self, textvariable=self.status)
self.statusbar.grid(sticky="we", row=3, padx=10)

# notebook
nb = ttk.Notebook(self)

self.tab1 = ttk.Frame(nb) # activities
self.tab2 = ttk.Frame(nb) # people
self.tab3 = ttk.Frame(nb) # locations
self.tab4 = ttk.Frame(nb) # organizations
self.tab5 = ttk.Frame(nb) # reports
self.tab6 = ttk.Frame(nb) # lookup tables

nb.add(self.tab1, text='Activities')
nb.add(self.tab2, text='People')
nb.add(self.tab3, text='Locations')
nb.add(self.tab4, text='Organizationbs')
nb.add(self.tab5, text='Reports')
nb.add(self.tab6, text='Lookups')


if __name__ == "__main__":
app = Application()
app.mainloop()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Writing a Python3 ttk.Notebook

2021-01-15 Thread Rich Shepard

On Fri, 15 Jan 2021, MRAB wrote:

You should be adding the frames to the notebook. Also, the tabs are 
'self.tab1', not 'tab1', etc:

n.add(self.tab1, text='Activities')
Similarly for the others.


Thanks. MRAB. This allows me to move on and put pre-built widget pages on
the tabs.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Writing a Python3 ttk.Notebook

2021-01-15 Thread Rich Shepard

I want to replace the menu on my application with the more appropriate
notebook. After looking at examples in my reference books and on the Web I
still cannot get it working properly.

Here's a small example (nbtest.py):
---8< ---
#!/usr/bin/env python3

import tkinter as tk
from tkinter import ttk
from tkinter.ttk import Notebook as n

class Test(tk.Tk):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# notebook
n = ttk.Notebook(self)

self.tab1 = ttk.Frame(n) # activities
self.tab2 = ttk.Frame(n) # people
self.tab3 = ttk.Frame(n) # locations
self.tab4 = ttk.Frame(n) # organizations
self.tab5 = ttk.Frame(n) # reports
self.tab6 = ttk.Frame(n) # lookup tables

self.add(tab1, text='Activities')
self.add(tab2, text='People')
self.add(tab3, text='Locations')
self.add(tab4, text='Organizations')
self.add(tab5, text='Reports')
self.add(tab6, text='Lookups')

n.pack(expand = 1, fill ="both")

if __name__ == "__main__":
app = Test()
app.mainloop()
>8 -

python-3.9.1 returns:
$ ./nbtest.py 
Traceback (most recent call last):

  File "/home/rshepard/development/business_tracker/./nbtest.py", line 32, in 

app = Test()
  File "/home/rshepard/development/business_tracker/./nbtest.py", line 22, in 
__init__
self.add(tab1, text='Activities')
  File "/usr/lib64/python3.9/tkinter/__init__.py", line 2346, in __getattr__
return getattr(self.tk, attr)
AttributeError: '_tkinter.tkapp' object has no attribute 'add'

Explanation of the error and suggestions for ttk.notebook references are
needed.

TIA,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: FridayFinking - Was: A beginning beginner's question about input, output and . . .

2021-01-13 Thread Rich Shepard

On Thu, 14 Jan 2021, dn via Python-list wrote:


Concerning the definition of "old"
- when I'm having a 'good day', it's anyone several years my senior (and
above)
- when I'm creaking and groaning, it's anyone remotely my age, and older.


About 45 years ago a 25-year-older friend of mine offered a great philosophy
of life. "We can do nothing about growing older," she told me, "but we can
do everything about growing old."

How true.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Application window geometry specifier

2021-01-12 Thread Rich Shepard

On Tue, 12 Jan 2021, Grant Edwards wrote:


And those X11 users will swear at you if you override their window
managers configured window placement. Application code should not care
about or try to control window geometry. Period.


Grant,

Since this application is my own business use those users can swear all they
want. :-) If I decide to post all the code on github other can modify it to
their heart's delight. They can even make it work on their wrist computer
(formerly known as a wrist watch.)

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Binding menu accelerator to a callback

2021-01-12 Thread Rich Shepard

Menu options work from the menu, but not from the accelerator associated
with that menu item. My research suggests that while 'command' works for the
menu item, 'bind' is required for the associated accelerator. For example,
File -> Quit is defined this way:

self.file_menu.add_command(
label="Quit",
command=self.fileQuit,
underline=0,
accelerator='Ctrl+Q'
)
and works when I pull down the File menu and click on 'Quit.'

I want to modify the menu items so the accelerator is bound to the same
self.fileQuit() (in this case). My web research hasn't found a solution
since examples for using bind() aren't in menus.

Do I need another method that associates accelerators with the callbacks?

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Application window geometry specifier

2021-01-12 Thread Rich Shepard

On Tue, 12 Jan 2021, Igor Korot wrote:


Maybe. :-)
But it looks Wayland becomes more and more popular.


Igor,

What I've read from those struggling to use Wayland, it may turn out to be a
popular as systemd. :-)

It's important to remember that while all progress involves change, not all
change involves progress.

Regards,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Application window geometry specifier

2021-01-12 Thread Rich Shepard

On Tue, 12 Jan 2021, Igor Korot wrote:


Keep in mind that if you target Linux, the "modern" window server
(Wayland) will not allow user code to decide the positioning and size of
the TLW.


Igor,

I suspect that Slackware will continue with X11.

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: Application window geometry specifier [RESOLVED]

2021-01-12 Thread Rich Shepard

On Wed, 13 Jan 2021, Chris Angelico wrote:


Do the offsets need to be integers?


ChrisA,

Yep. I totally missed that.

Thanks for seeing it.

Stay well,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Application window geometry specifier

2021-01-12 Thread Rich Shepard

I want my application's window (main frame) to open centered on the
monitor's screen. This code:
# open application centered on screen; set window width and height
self.appwidth = 600
self.appheight = 500
# get screen width and height
self.scrwidth = self.winfo_screenwidth()
self.scrheight = self.winfo_screenheight()
# formula to find screen center
self.xLeft = (self.scrwidth/2) - (self.appwidth/2)
self.yTop = (self.scrheight/2) - (self.appheight/2)
# set geometry
self.geometry(str(self.appwidth) + "x" + str(self.appheight) +
  "+" + str(self.xLeft) + "+" + str(self.yTop))

generates this error when run:
 File "/usr/lib64/python3.9/tkinter/__init__.py", line 2036, in wm_geometry
return self.tk.call('wm', 'geometry', self._w, newGeometry)
_tkinter.TclError: bad geometry specifier "600x500+340.0+262.0"

As the geometry string represents window width times window height plus x-offset
plus y-offset I'm not seeing my error.

Please show me what's wrong with specifier.

TIA,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: tkinter: creating/attaching menubar to top level window

2021-01-08 Thread Rich Shepard

On Fri, 8 Jan 2021, Richard Damon wrote:


It could be either:
self.menu = menubar
or
self['menu'] = menubar


Got it, Richard. Removed the period after 'self'.

Thanks,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


Re: tkinter: creating/attaching menubar to top level window [RESOLVED]

2021-01-08 Thread Rich Shepard

On Fri, 8 Jan 2021, Christian Gollwitzer wrote:


It is a simple typo, remove the dot.
self['menu'] = menubar
It will then stop at the add_cascade, fix it like this:


Christian,

Well, I totally missed that because I'm used to adding a period after each
self. Your fresh eyes saw what I kept missing,


menubar.add_cascade(menu=self.menu_file, label='File')


I was going to add the 'self' there when I found what stopped the processing
before it.

Many thanks.

Stay well and carpe weekend,

Rich
--
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   >