Posts by Marcio Luís • 1,061 points
14 posts
-
1
votes1
answer98
viewsQ: What signal to use for firing methods from a pygtk thread?
I have a Tree View that I need popular with data obtained in a thread, but if I do it from it the program presents several random problems and errors. Researching found that the ideal is to trigger…
-
1
votes1
answer649
viewsA: How to place the mouse cursor in a specific position of a text field?
I went through the same problem, and I used the following: campo.set_position(-1) To make it easy I made an example, where the text cursor will always go to the end. from gi.repository import Gtk,…
-
3
votes1
answer169
viewsQ: How to change the width of columns in the Admin listing in Django?
How do I specify the width for the columns that are displayed in the Admin listing, more precisely the ones I specify in list_display in admin.py. Researching I found similar question here, where I…
-
7
votes3
answers27933
viewsQ: Python str.replace() doubt
I have the following text:: 'box 1 is blue, box 10 is green, box 100 is empty' I want to replace 'box 1' with 'package 2', so I do: >>> texto = 'caixa 1 é azul, caixa 10 está verde, caixa…
-
4
votes1
answer1443
viewsQ: What is the difference between dump and dumps from the Pickle module in Python?
I have read the documentation of Python and also of Pickle himself, but I could not assimilate the content (lack of examples). On the Web I only found information about using "dump + load" and…
-
0
votes3
answers271
viewsA: How to allow only one instance of a certain class?
I found a solution until feasible for the issue of allowing only one instance of certain window in Gtk #!/usr/bin/env python3 # -*- coding: utf-8 -*- from gi.repository import Gtk class…
-
8
votes1
answer349
viewsQ: In Python, how do you explain the expression 'x = not x'
I already know the result, but I would like to understand what happens, why of such a result... For example: >>> a = True >>> b = not a >>> print(b) False It’s a simple…
-
21
votes3
answers553
viewsQ: In Python, what are the consequences of using is instead of '=='
The two forms below return True, but what are the consequences of this in a more complex code? >>> a = '2' >>> a is '2' >>> True >>> a == '2' >>> True…
-
1
votes3
answers8272
viewsA: How to call external command with Python?
You can also use subprocess import subprocess subprocess.call('ls', shell = True)
-
7
votes2
answers5650
viewsQ: How to Direct Commands to the Linux Python Terminal
I need to create a script in Phyton that when executed is via mouse click or keyboard 'enter', it opens the linux terminal itself and execute any command inside it. I have already managed to get him…
-
8
votes2
answers1172
viewsQ: In Python, is there any rule or advantage regarding the use of 'Self'?
Let us consider the examples below: Example 1: > class PrintText(): > def __init__(self): > text = 'Funciona!' > self.printa(text) > > def printa(self, text): > print(text)…
-
4
votes1
answer256
viewsQ: How to allow just one instance of a program made in Python?
Assuming I created a program in Python and it is working perfectly, how do I allow just one instance of the program at a time? I Googled and found a person saying to have solved the issue using…
-
4
votes3
answers271
viewsQ: How to allow only one instance of a certain class?
If we execute the code below, a window will be created with a button inside, that every clicked will open another window (Window2)... How do I not allow a second instance of Window2? I want to do…
-
23
votes1
answer15547
viewsQ: How is 'super' used in Python classes and what is it used for?
How to use and for what purpose super in classes Python?