internationalization and root privilege

40 views
Skip to first unread message

Георги Никифоров

unread,
Nov 14, 2012, 1:37:28 PM11/14/12
to wxpytho...@googlegroups.com
Dear all,

I have two questions regarding wxpython.

1) I am writing a program, which needs to have a couple of buttons with
labels having non-English characters. I tried following the
internalization tutorial:
> http://zetcode.com/wxpython/in18/
I made sure that I've compiled wxpython with unicode support and then
got the unicode versions of the strings using the python command
>>>unicode(u'<string>')
However when I run the program, I get just garbage as opposed to the
unicode characters. Any ideas what the problem might be.

2) I am trying to create a simple program, which should edit a file in
the root directory of a computer. So I would like to be able to run this
program as a superuser. Therefore if a normal user is running that
program, I would like to create a pop-up window, where the user can add
the superuser password in order to make changes to the file. I guess
ideally what I would like to have is a similar behaviour to what happens
when one runs synaptic in Ubuntu. Unfortunately I was not able to find a
tutorial how to do that. Can someone point me to the right resource so
that I can achieve this task in a secure way?

Thanks a lot,
George

Werner

unread,
Nov 14, 2012, 1:45:40 PM11/14/12
to wxpytho...@googlegroups.com
On 14/11/2012 19:37, Георги Никифоров wrote:
> Dear all,
>
> I have two questions regarding wxpython.
>
> 1) I am writing a program, which needs to have a couple of buttons with
> labels having non-English characters. I tried following the
> internalization tutorial:
>> http://zetcode.com/wxpython/in18/
> I made sure that I've compiled wxpython with unicode support and then
> got the unicode versions of the strings using the python command
>>>> unicode(u'<string>')
> However when I run the program, I get just garbage as opposed to the
> unicode characters. Any ideas what the problem might be.
Do you have the following (with appropriate encoding) at the top of your
source code?
# -*- coding: utf-8 -*-#

Are your .mo files correctly encoded?

The Phoenix doc and the wiki have some more info:
http://wxpython.org/Phoenix/docs/html/internationalization.html?highlight=internationalization

Werner

Георги Никифоров

unread,
Nov 18, 2012, 12:42:10 PM11/18/12
to wxpython-users
Hi Werner,

Thanks for your reply. I guess I don't have a .po or .mo file. I was
just hoping that I can just put non-ascii character for the labels on
the buttons and that would work. But I guess that was wrong. So I will
read through the link you gave me but I guess it is a bit more
involved that I had originally thought.

Thanks!

Werner

unread,
Nov 18, 2012, 12:49:55 PM11/18/12
to wxpytho...@googlegroups.com
Hi,

On 18/11/2012 18:42, Георги Никифоров wrote:
>
>> Do you have the following (with appropriate encoding) at the top of
>> your source code?
>> # -*- coding: utf-8 -*-#
>>
>> Are your .mo files correctly encoded?
>>
>> The Phoenix doc and the wiki have some more info:
>> http://wxpython.org/Phoenix/docs/html/internationalization.html?highlight=internationalization
> Hi Werner,
>
> Thanks for your reply. I guess I don't have a .po or .mo file. I was
> just hoping that I can just put non-ascii character for the labels on
> the buttons and that would work. But I guess that was wrong. So I will
> read through the link you gave me but I guess it is a bit more
> involved that I had originally thought.
If you just want non-ascii and not translate to other languages then
having the following at the top of your source file should do the trick,
assuming that your editor respects this or if you manually encode your
files as "utf-8" (or whatever you define in the line.

# -*- coding: utf-8 -*-#

http://www.python.org/dev/peps/pep-0263/

Werner

Георги Никифоров

unread,
Nov 18, 2012, 2:01:40 PM11/18/12
to wxpytho...@googlegroups.com
This did the trick! Thanks a lot!

niki

unread,
Nov 19, 2012, 3:58:34 AM11/19/12
to wxpytho...@googlegroups.com, Георги Никифоров
On 14.11.2012 20:37, Георги Никифоров wrote:
> 2) I am trying to create a simple program, which should edit a file in
> the root directory of a computer. So I would like to be able to run this
> program as a superuser. Therefore if a normal user is running that
> program, I would like to create a pop-up window, where the user can add
> the superuser password in order to make changes to the file. I guess
> ideally what I would like to have is a similar behaviour to what happens
> when one runs synaptic in Ubuntu. Unfortunately I was not able to find a
> tutorial how to do that. Can someone point me to the right resource so
> that I can achieve this task in a secure way?

Try gksu/gksudo

Поздрави.
Ники

Георги Никифоров

unread,
Nov 20, 2012, 5:27:53 AM11/20/12
to wxpytho...@googlegroups.com
Thanks a lot! Really appreciated!

Георги

Robin Dunn

unread,
Nov 20, 2012, 1:51:38 PM11/20/12
to wxpytho...@googlegroups.com
On 11/14/12 10:37 AM, Георги Никифоров wrote:
> 2) I am trying to create a simple program, which should edit a file in
> the root directory of a computer. So I would like to be able to run this
> program as a superuser. Therefore if a normal user is running that
> program, I would like to create a pop-up window, where the user can add
> the superuser password in order to make changes to the file. I guess
> ideally what I would like to have is a similar behaviour to what happens
> when one runs synaptic in Ubuntu. Unfortunately I was not able to find a
> tutorial how to do that. Can someone point me to the right resource so
> that I can achieve this task in a secure way?

I don't remember for sure how it is doing it, but the Esky package has
the ability to elevate privileges to root/admin on all 3 platforms, so
if you want to be able to do this on multiple platforms then you may
want to dive into their code to get some ideas.

--
Robin Dunn
Software Craftsman
http://wxPython.org

Георги Никифоров

unread,
Nov 21, 2012, 9:27:51 AM11/21/12
to wxpytho...@googlegroups.com
Thanks a lot for the suggestion. Will take a look.
Cheers!

2012/11/20 Robin Dunn <ro...@alldunn.com>

Reply all
Reply to author
Forward
0 new messages