Some Basic questions on the use of CTRL and ALT Keys

J

joy99

Dear Group,

I have written a small and simple program like the following:

def alphabet1(n):
file_open=open("/python26/alphabetlist1.txt","r")
file_read=file_open.read()
file_word=file_read.split()
print file_word

Here, I am using a file “alphabetlist1.txt” which I am reading and
then splitting them into words.

In this file “alphabetlist1.txt” I have arranged few alphabets like
the following:

a A
b B
c C
d D
E e
F f

Where, a/b/c/d/e/f are in lower case and A/B/C/D/E/F are in upper
case which I can say as
SHIFT+a
SHIFT+b
SHIFT+c
SHIFT+d
SHIFT+e
SHIFT+f

Now, in the list or anywhere in the program if I want to write
CTRL+a/b/c/d/e/f or ALT+a/b/c/d/e/f for which I may assign any value I
may feel not only cut/copy/paste.

How would I represent them?

It may not be a Python specific question but as this room is full with
many expert programmers if someone can help me out.

I copied the above program from .py file to a word processor like MS-
WORD so some indentation might have changed, I am sorry for the same.

Regards,
Subhabrata Banerjee.
 
S

Steven D'Aprano

Dear Group,

I have written a small and simple program like the following:

def alphabet1(n):
file_open=open("/python26/alphabetlist1.txt","r")
file_read=file_open.read()
file_word=file_read.split()
print file_word

Here, I am using a file “alphabetlist1.txt†which I am reading and then
splitting them into words.

In this file “alphabetlist1.txt†I have arranged few alphabets like the
following:

a A
b B
c C
d D
E e
F f

Where, a/b/c/d/e/f are in lower case and A/B/C/D/E/F are in upper case
which I can say as
SHIFT+a
SHIFT+b
SHIFT+c
SHIFT+d
SHIFT+e
SHIFT+f

Now, in the list or anywhere in the program if I want to write
CTRL+a/b/c/d/e/f or ALT+a/b/c/d/e/f for which I may assign any value I
may feel not only cut/copy/paste.

How would I represent them?

This question is badly defined. What are your constraints? Is this meant
to be a human-readable program? If so, you need to stick to ASCII text
and probably want something like:

a A CTRL-A ALT-A
b B CTRL-B ALT-B
....

but I'm not sure what the point of that would be.

Normally, control-combinations generate control-characters. For example,
CTRL-M would normally generate a carriage-return character. Depending on
your needs, you can write this as any of the following:

a description: CTRL-M
an escape sequence: \r
caret notation: ^M
the standard abbreviation: CR
the Unicode display glyph: â
or an actual carriage-return character.


Note that in ASCII control characters only have a standard definition for
the following:

ctrl-@
ctrl-A through ctrl-Z
ctrl-[
ctrl-\
ctrl-]
ctrl-^
ctrl-_
ctrl-?


See here for more:
http://en.wikipedia.org/wiki/Control_characters


As for Alt-combinations, I don't think there is any standard for what
they are. I believe that they are operating system specific, and possibly
even program specific.
 
J

joy99

Dear Group,
I have written a small and simple program like the following:
def alphabet1(n):
    file_open=open("/python26/alphabetlist1.txt","r")
    file_read=file_open.read()
    file_word=file_read.split()
    print file_word
Here, I am using a file “alphabetlist1.txt†which I am reading and then
splitting them into words.
In this file “alphabetlist1.txt†I have arranged few alphabets like the
following:
a A
b B
c C
d D
E e
F f
Where, a/b/c/d/e/f are in  lower case and A/B/C/D/E/F are in upper case
which I can say as
SHIFT+a
SHIFT+b
SHIFT+c
SHIFT+d
SHIFT+e
SHIFT+f
Now, in the list or anywhere in the program if I want to write
CTRL+a/b/c/d/e/f or ALT+a/b/c/d/e/f for which I may assign any value I
may feel not only cut/copy/paste.
How would I represent them?

This question is badly defined. What are your constraints? Is this meant
to be a human-readable program? If so, you need to stick to ASCII text
and probably want something like:

a A CTRL-A ALT-A
b B CTRL-B ALT-B
...

but I'm not sure what the point of that would be.

Normally, control-combinations generate control-characters. For example,
CTRL-M would normally generate a carriage-return character. Depending on
your needs, you can write this as any of the following:

a description: CTRL-M
an escape sequence: \r
caret notation: ^M
the standard abbreviation: CR
the Unicode display glyph: â
or an actual carriage-return character.

Note that in ASCII control characters only have a standard definition for
the following:

ctrl-@
ctrl-A through ctrl-Z
ctrl-[
ctrl-\
ctrl-]
ctrl-^
ctrl-_
ctrl-?

See here for more:http://en.wikipedia.org/wiki/Control_characters

As for Alt-combinations, I don't think there is any standard for what
they are. I believe that they are operating system specific, and possibly
even program specific.

Dear Sir,

I was writing a transliteration program from Bengali to English and
vice versa. The program using Unicode chart is giving me perfect
outputs in Bengali and vice versa with Bengali input -> English.
I wanted to add some more power to the key board entry scheme, as I
have developed few fonts also and now trying to work out a windows
based word processor in Bengali.
Thank you for your kind answer.
It helped me lot.
ALT portion I'll work out on my own.
Sorry for a wrongly given problem statement.
Wishing you a happy day ahead,
Regards,
Subhabrata.
 
J

joy99

Dear Group,
I have written a small and simple program like the following:
def alphabet1(n):
    file_open=open("/python26/alphabetlist1.txt","r")
    file_read=file_open.read()
    file_word=file_read.split()
    print file_word
Here, I am using a file “alphabetlist1.txt†which I am reading and then
splitting them into words.
In this file “alphabetlist1.txt†I have arranged few alphabets like the
following:
a A
b B
c C
d D
E e
F f
Where, a/b/c/d/e/f are in  lower case and A/B/C/D/E/F are in upper case
which I can say as
SHIFT+a
SHIFT+b
SHIFT+c
SHIFT+d
SHIFT+e
SHIFT+f
Now, in the list or anywhere in the program if I want to write
CTRL+a/b/c/d/e/f or ALT+a/b/c/d/e/f for which I may assign any value I
may feel not only cut/copy/paste.
How would I represent them?

This question is badly defined. What are your constraints? Is this meant
to be a human-readable program? If so, you need to stick to ASCII text
and probably want something like:

a A CTRL-A ALT-A
b B CTRL-B ALT-B
...

but I'm not sure what the point of that would be.

Normally, control-combinations generate control-characters. For example,
CTRL-M would normally generate a carriage-return character. Depending on
your needs, you can write this as any of the following:

a description: CTRL-M
an escape sequence: \r
caret notation: ^M
the standard abbreviation: CR
the Unicode display glyph: â
or an actual carriage-return character.

Note that in ASCII control characters only have a standard definition for
the following:

ctrl-@
ctrl-A through ctrl-Z
ctrl-[
ctrl-\
ctrl-]
ctrl-^
ctrl-_
ctrl-?

See here for more:http://en.wikipedia.org/wiki/Control_characters

As for Alt-combinations, I don't think there is any standard for what
they are. I believe that they are operating system specific, and possibly
even program specific.

It seems the following site:
http://knopok.net/symbol-codes/alt-codes
is quite resourceful on Alt.
Regards,
Subhabrata.
 
L

Lie Ryan

I was writing a transliteration program from Bengali to English and
vice versa. The program using Unicode chart is giving me perfect
outputs in Bengali and vice versa with Bengali input -> English.
I wanted to add some more power to the key board entry scheme, as I
have developed few fonts also and now trying to work out a windows
based word processor in Bengali.
Thank you for your kind answer.
It helped me lot.
ALT portion I'll work out on my own.
Sorry for a wrongly given problem statement.
Wishing you a happy day ahead,
Regards,
Subhabrata.

If I haven't misunderstood you, you want to capture keyboard input
involving the CTRL and ALT key, am I correct?

Getting keyboard input with modifier keys depends on your GUI widgets.
Which are you using? Tkinter? wxWidget? PyQT? or plain ol' terminal?
 
J

joy99

If I haven't misunderstood you, you want to capture keyboard input
involving the CTRL and ALT key, am I correct?

Getting keyboard input with modifier keys depends on your GUI widgets.
Which are you using? Tkinter? wxWidget? PyQT? or plain ol' terminal?

You are very right. I am using IDLE on WinXP and for building GUI-
TKinter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top