python-3.2

Python/Gtk3 : How to add a Gtk.Entry to a Gtk.MessageDialog?

痴心易碎 提交于 2019-12-01 22:03:35
Good morning, I'm trying to add a Gtk.Entry to a Gtk.MessageDialog . With the following code it seems that I added the Gtk.Entry but it's not visible on the dialog window (Python3/Gtk3) : #!/usr/bin/python3 from gi.repository import Gtk def get_user_pw(parent, message, default=''): dialogWindow = Gtk.MessageDialog(parent, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK_CANCEL, message) dialogBox = dialogWindow.get_content_area() userEntry = Gtk.Entry() userEntry.set_visibility(False) userEntry.set_invisible_char("*") userEntry.set_size

Install pip<v8 in python3.2

喜你入骨 提交于 2019-12-01 07:32:31
问题 I fail to install pip in python3.2. The newest version of pip (v8.x) seems to not support python3.2 any more. So i tried: sudo python3 get-pip.py 'pip<8' but it still seems to install v8.x. Output: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here. Traceback (most recent call last): File "get-pip.py", line 19178, in <module> main() File "get-pip.py", line 195, in main bootstrap(tmpdir=tmpdir) File "get-pip.py", line 82, in bootstrap import pip File "/tmp

Finding a process ID given a socket and inode in Python 3

假如想象 提交于 2019-11-30 16:06:25
问题 /proc/net/tcp gives me a local address, port, and inode number for a socket (0.0.0.0:5432 and 9289, for example). I'd like to find the PID for a specific process, given the above information. It's possible to open every numbered folder in /proc, and then check symlinks for matching socket/inode numbers with a shell command like "$ sudo ls -l /proc/*/fd/ 2>/dev/null | grep socket". However, this seems more computationally expensive than necessary, since <5% of the processes on any given system

Finding a process ID given a socket and inode in Python 3

≡放荡痞女 提交于 2019-11-30 15:55:20
/proc/net/tcp gives me a local address, port, and inode number for a socket (0.0.0.0:5432 and 9289, for example). I'd like to find the PID for a specific process, given the above information. It's possible to open every numbered folder in /proc, and then check symlinks for matching socket/inode numbers with a shell command like "$ sudo ls -l /proc/*/fd/ 2>/dev/null | grep socket". However, this seems more computationally expensive than necessary, since <5% of the processes on any given system have open TCP sockets. What's the most efficient way to find the PID which has opened a given socket?

Uninstall python 3.2 on mac os x 10.6.7

若如初见. 提交于 2019-11-30 05:12:07
According to the documentation from python.org, python 3.2 install on mac os requires an upgrade to tcl/tk 8.5.9 (for use of IDLE). In my haste, I have done both. Now my friend told me that python 3 is not recommended yet because only the built-ins and a few modules have been released for 3. The stable one so far is 2.7 (especially if one wants to make extensive use of a variety of modules). My machine has both 2.6.1 and 3.2 (because some OS services make use of 2.6.1 that comes as default with the OS). 1. How do i remove 3.2 completely to avoid any compatibility issues? tcl/tk 8.5.9 was also

python centre string using format specifier

无人久伴 提交于 2019-11-28 21:15:13
I have a string called Message. Message = "Hello, welcome!\nThis is some text that should be centered!" Yeah, it's just a test statement... And I'm trying to centre it for a default Terminal window, i.e. of 80 width, with this statement: print('{:^80}'.format(Message)) Which prints: Hello, welcome! This is some text that should be centered! I'm expecting something like: Hello, welcome! This is some text that should be centered! Any suggestions? You need to centre each line separately: '\n'.join('{:^80}'.format(s) for s in Message.split('\n')) Here is an alternative that will auto center your

Why is `None` returned instead of tkinter.Entry object?

↘锁芯ラ 提交于 2019-11-28 08:21:17
问题 I'm new to python, poking around and I noticed this: from tkinter import * def test1(): root = Tk() txtTest1 = Entry(root).place(x=10, y=10) print(locals()) def test2(): root = Tk() txtTest2 = Entry(root) txtTest2.place(x=10, y=10)#difference is this line print(locals()) test1() test2() outputs contain: 'txtTest1': None 'txtTest2': <tkinter.Entry object at 0x00EADD70> Why does test1 have a None instead of <tkinter.Entry object at ... ? I'm using python 3.2 and PyScripter. 回答1: The place

How to read an array of integers from single line of input in python3

和自甴很熟 提交于 2019-11-28 00:25:18
I want to read an array of integers from single line of input in python3. For example: Read this array to a variable/list 1 3 5 7 9 What I have tried arr = input.split(' ') But this does not convert them to integers. It creates array of strings arr = input.split(' ') for i,val in enumerate(arr): arr[i] = int(val) 2nd one is working for me. But I am looking for an elegant(Single line) solution. Saullo G. P. Castro Use map : arr = list(map(int, input().split())) Just adding, in Python 2.x you don't need the to call list() , since map() already returns a list , but in Python 3.x "many processes

UnicodeEncodeError: 'ascii' codec can't encode character in position 0: ordinal not in range(128)

巧了我就是萌 提交于 2019-11-27 18:09:55
I'm working on a Python script that uses the scissor character (9986 - ✂) and I'm trying to port my code to Mac, but I'm running into this error. The scissor character shows up fine when run from IDLE (Python 3.2.5 - OS X 10.4.11 iBook G4 PPC) and the code works entirely fine on Ubuntu 13.10, but when I attempt to run this in the terminal I get this error/traceback: Traceback (most recent call last): File "snippets-convert.py", line 352, in <module> main() File "snippets-convert.py", line 41, in main menu() File "snippets-convert.py", line 47, in menu print ("|\t ",snipper.decode(),"PySnipt'd"

Identifying the data type of an input

孤街醉人 提交于 2019-11-27 07:01:18
问题 Hi I am trying to print the data type of a user input and produce a table like following: ABCDEFGH = String, 1.09 = float, 0 = int, true = bool , etc. I'm using python 3.2.3 and I know I could use type() to get the type of the data but in python all user inputs are taken as strings and I don't know how to determine whether the input is a string or Boolean or integer or float. Here is that part of the code: user_var = input("Please enter something: ") print("you entered " + user_var) print