15,175 Topics
| |
from gimpfu import * def do_message_box(msg): handler = pdb.gimp_message_get_handler() pdb.gimp_message_set_handler(MESSAGE_BOX) #{ MESSAGE-BOX (0), CONSOLE (1), ERROR-CONSOLE (2) } pdb.gimp_message(msg) pdb.gimp_message_set_handler(handler) def add_steg_text(image, layer, text): length = len(text) # limit length of message to 255 if length > 255: do_message_box("text too long! (don't exeed 255 characters)") return pdb.gimp_image_undo_group_start(image) newlayer = layer.copy() … | |
The following lower case letters are written partly below the **baseline: g, j, p, q, y.** We say that these letters have a descender. Write a function named hasDescender() that returns a list of those words in a string in which at least one letter has a descender. A word … | |
how would you work out speed between two sensors which is 500m apart. using speed=distance/time. when the car enters the first sensor say the time was 3:00 58 seconds. and the second sensor is 3:01 26 seconds. then the difference between the times ill be used in the formula, so … | |
from collections import deque def search(lines,pattern,history=5): previous_lines = deque(maxlen=history) for line in lines: if pattern in line: yield line,previous_lines previous_lines.append(line) if __name__ == "__main__": with open('history') as f: for line,prevlines in search(f,'python',5): for pline in prevlines: print( pline , end ='') print('-' * 20) Can someone help me to understand … | |
I am trying to create a GUI using Tkinter, that reads in serial data. I eventually want multiple check buttons (for each possible port), and when the checkbutton is clicked, I would like the raw data from the port to continuously print onto a textbox in the GUI. I did … | |
I want to know addresses of some coordinates, so I use geopy-1.10. my code is from geopy.geocoders import Nominatim def to_degrees(lats, longs): lat_deg = lats[0:2] lat_mins = lats[2:4] lat_secs = int(lats[5:])*60/10000 lat_msecs = int(lats[5:])*60%10000 lat_str = lat_deg + u'.'+ lat_mins + str(lat_secs) + str(lat_msecs) lon_deg = longs[0:3] lon_mins = longs[3:5] … | |
Hello, I want to know addresses of some coordinates, so I use geopy. my code is from geopy.geocoders import Nominatim def to_degrees(lats, longs): lat_deg = lats[0:2] lat_mins = lats[2:4] lat_secs = int(lats[5:])*60/10000 lat_msecs = int(lats[5:])*60%10000 lat_str = lat_deg + u'.'+ lat_mins + str(lat_secs) + str(lat_msecs) lon_deg = longs[0:3] lon_mins = … | |
This is kinda a poll. Please reply, and answer the 2 questions shortly, so I can get a grasp of your feedback. I want to know if there is a desire for this, or if it already exists. Years ago I started to work on a python program called "spellcheck-dir" … | |
Hello, I'm trying to make timer which spit out gps signal every 10 or 60 seconds. here is my code. * **import threading import time import serial import datetime, string from pynmea import nmea def init_serial(): COMNUM = 13 global ser ser = serial.Serial() ser.baudrate = 9600 ser.port = 12 … | |
ok, so I'm trying to basically load a dll that can be under multiple names: - freetype6 - libfreetype-6 and more I don't want it to find freetype.dll (I want it to search for 'freetype' and '6') how can I load a dll with a regex from the system paths?? … | |
A strange phenomenon! What is this number 8! We are in the 2.7 version of Python. **MY CODE ** x = raw_input("write a list! utilisation of raw_input ") y = input("write a list! utilisation of input ") print x, "resultat of rawinputation" print y, "resultat of inputation" **My input and … | |
hey everyone im making a program that takes a number (n) from the user and then decides if it is prime or not and prints that decision to the screen [CODE] from math import * def main(): n=eval(input("please enter the number you wish to check:")) n=abs(n) if n < 2: … | |
**Part A.** Define a function triangle that draws an equilateral triangle and takes two parameters: 1. t, a turtle object 2. size, the side length of an equilateral triangle **Part C:** Define a function flagLine that takes 3 parameters and draws a line of flags (triangles). You MUST use the … | |
This 'sticky' thread is for working examples of Python GUI code. Note that most wxPython examples have their own thread. Please use comments in your code to help the reader. The example code should be usable as a template, so folks get a feel for the toolkit and can use … | |
Hey guys, I need some help with my code because I have a bit of trouble with changing the 12 hours time when I'm trying to change the strings in the object. When I try this: def GoLeft(self): if CurrentRow == 375: if self.channel_page >= 0: # Set the date … | |
ok, so this is a bit complex, I'm writing a bit-field function using a template, which can consist of: field( Template, Value ) field( [1,7,15] ,255 ) #int representation... field( ['1','3','4'] ,255 ) #bit representation... #>>> [1,7,15] field( [1,7,15] ,[1,7,15] ) field( ['1','3','4'] ,[1,7,15] ) #>>> 255 so what I'm … | |
In my quest to learn more regarding programming in Python, I "dissect" a lot of other people's code. While doing this, or writing my own code, I end up with 10's of debug print lines. Things like this: if v_Debug == 1: print("DEBUG - ".format()) # DEBUG If I decide … | |
I, and many others, desired a "switch" keyword in Python. For me it was to a desire to make some of my code more compact and readable, as I often have many user selected options for the code to weed through. So I set off on a journey to figure … | |
Hello, people. A newbie here... sorry. A hired programmer (who doesn't use Windows) is writing a Python thing for me, On my Windows 7 PC, I installed Python v 3.4.3, and he says that I need to install certain non-standard modules... lxml, requests and xlwt from http://lxml.de/ http://docs.python-requests.org/en/latest/ https://pypi.python.org/pypi/xlwt Trying … | |
Hello all, I haven't joined a forum in probably 10 years. I am joining this one, actually because I had issues with the sister site, programmingforums.org Apparently my account is in limbo there (activated, but not approved by a moderator). Originally, when attempting to join the other site, it was … | |
I have made a program that reads a file and its main function does some geographic computations to the contents inside. It works now, but instead I want the program to write it instead to a file instead of printing it. I don't understand how to write it because this … | |
basically, what I want to do is add a function name to an outside reference in a safe sys.modules reference without copying the name... best idea I got is to call a 3rd party function: def myfunc(args): x = None return x addname() # add 'myfunc' to sys.modules['/safe_ref/'] anyone got … | |
I'm currently creating the game checkers(draughts) and have problem moving the pieces on the board. So far I have all the pieces on one side of the board ready where each piece is it's own function. For the pieces to move i've created a function called mousePressEvent. It takes the … | |
The question is: Is it simple to build a GUI that can be accessible remotely? We worked a lot on this and we built a GUI library, portable, lightweight, Python! Hosted on github https://github.com/dddomodossola/gui Here is an example (suggestions are gratefully accepted :-) ): import gui from gui import * … | |
i need to write a loop program converting celsius to farenheit using the formula F=9*C/5+32 and terminating at -999 | |
Hey guys, I am making a few gui programs and I was wondering on this code .. class PaintChart(wx.Panel): def __init__(self, parent, data): self.data = data.split() wx.Panel.__init__(self, parent) self.SetBackgroundColour('BLACK') self.Bind(wx.EVT_PAINT, self.drawChart) def drawChart(self, e): dc = wx.PaintDC(self) dc.SetDeviceOrigin(30, 240) dc.SetAxisOrientation(True, True) dc.SetPen(wx.Pen('RED')) dc.DrawRectangle(1, 1, 300, 200) Here I set the … | |
#!/usr/bin/python import Evaluar from pylab import * from numpy import * def biseccion(a, b, TOL, N): Evaluar.dicc_seguro['x']=a fa = eval(Evaluar.funcion, {"__builtins__":None}, Evaluar.dicc_seguro) vectorx = zeros(N, Float64) vectory = zeros(N, Float64) i = 1 while i<=N : p = (a+b)/2.0 vectorx[i-1] = p Evaluar.dicc_seguro['x']=p fp = eval(Evaluar.funcion, {"__builtins__":None}, Evaluar.dicc_seguro) vectory[i-1]=fp if … | |
apparently this seems to be pretty unheard of because of the over-glorified NumPy extension, which yes is faster than using python alone, but most likely not as fast as defining the raw complex methods such as matrix inversion in plain C. with NumPy you need to make an array object … | |
| I have a 'User' model holding some information like username password etc. After installing swingtime I was hoping to correlate its 'Event' model with my 'User' model so I can add events for every individual user. The thing is that in order to do that I need to have a … |
import evaluar from pylab import * from numpy import * def puntofijo(po,TOL, N): vectorx = zeros (N, Float64) vectory = zeros (N, Float64) i = 1 while i<=N : vectorx[i-1] = po Evaluar.dicc_seguro['x']=po fp = eval(Evaluar.funcion, {"__builtins__":None}, Evaluar.dicc_seguro) vectory[i-1]=fp if fabs(po-fp): print "La raiz buscada es: ",po, "con", i-1, "iteraciones" … |
The End.