richieking 44 Master Poster

just clik on solve tab to close the thread

richieking 44 Master Poster

And where do you get the servo module from??
self written?

richieking 44 Master Poster

jsut provide the file path without the os.path.adspath call.
;)

richieking 44 Master Poster

if i were you, i will just convert and use cpicle or anydb

richieking 44 Master Poster

Well you can not just call your module and expect the imported modules to work right away.

Say we got text.py which contains...

import socket, re, time
import urllib.request, os, sys
import pickle
from RushFunctions impor

to have any of the imported modules called from text.py, you must inherit the module into your code in text.py like...

class foo(socket):
   def __init__():
    socket.__init__()

Then import the module into text2.py for action

from text import foo ## which is the socket
sock=foo.socket()
sock.start()

This is give you the idea on how to include a modules in a project like yours.
:)

richieking 44 Master Poster

To have the values inside the tages ... you do this
on line 31

print paramkey.text

Now using find all makes paramkey a list. Therefore you must iter. paramkey.

print([x.text for x in paramkey])

Hope you got the idea :)
show your love....

richieking 44 Master Poster

The syntax,algorithm and implementation are all diffrent. But the idea are the same.
Just as we got different make of cars but they can all take you to your destination.

The mechanics in the cars are somehow different but they works the same. You just have to understand how one works and its not difficult to know the other.
:)

richieking 44 Master Poster

Here is your full working code.

I just changed few thing.

def distanceConverter(dfrom, funit, dto, tunit):
    print dfrom
    print dto
    print funit
    print tunit


def distance():
    msg="1) Millimeters \n"
    msg+="2) Centimeters \n"
    print msg
#prints list of from options
    choice=raw_input("Select unit to convert from:")

    if choice in ('1','millimeters','Millimeters'):
        dfrom=1
        funit="millimeters"
    elif choice in ('2','centimeters','Centimeters'):
        dfrom=2
        funit="centimeters"
    else:
        print "Invalid entry. Please select 1 or 2"

    print msg
    choice=raw_input("Select unit to convert to:")

    if choice in ('1','millimeters','Millimeters'):
        dto=1
        tunit="millimeters"
    elif choice in('2','centimeters','Centimeters'):
        dto=2
        tunit="centimeters"
    else:
        print "Invalid entry. Please select 1 or 2"


    distanceConverter(dfrom,funit,dto,tunit)

def mass():
    print "mass function tester"
def velocity():
    print "velocity function tester"


def main():
    msg="Welcome to Rob's Unit Converter Build 1.0."
    print msg
#prints the opening message and list of unit options
    msg="1) Distance \n"
    msg+="2) Mass/Weight \n"
    msg+="3) Velocity"
    print msg
    choice=4
    while choice>3:
        choice=input("Please select the unit type:")
        if choice==1:
            distance()
        elif choice==2:
            mass()
        elif choice==3:
            velocity()
        else:
            print "Invalid selection, please enter 1, 2, or 3."
if __name__=='__main__':
    main()

Happy codding :)

richieking 44 Master Poster

backslash is native to windows as forwardslash to linux/unix/bsd file path. if you want to write an app. for network , then your good choice shout be forwardslash.

richieking 44 Master Poster

You are welcome goodfriend :)
you can upvote me a lil and close the thread
Thanks

richieking 44 Master Poster

Ok that means PYQT works and import fine but calling QFileDialog provides error. right?
Then i guess you need to look through QT docs about QFileDialog. ;)

richieking 44 Master Poster

Your error was very clear.

the

os.stat("path to file")

But you have only provided the file name.

richieking 44 Master Poster

Check if there is a pyqt for py2.7.
go to pyqt and look for py2.7 compability version. matbe the version is not supported on py2.7 ok.?

richieking 44 Master Poster

just start your wxpy app. and when you see your window. just hit ALT tab are the menu underline will be visible.

richieking 44 Master Poster

rscubelek

strip() can save a lot when taking user inputs.
Try and split() your user inputs and you have saved yourself 80% of worries. check this out.

foo=" hello" #1
foo="hello"  #2

The 2 foos variables are not the sane from user inputs with the check of equality sign ==.

They are only the same after strip() is called.
:)

richieking 44 Master Poster

There are 3 things going on with your script.
1. a is global variable assigned the value of 10.
2. You function is a function that has a default value set. that is global a which got the value of 10.
due to that

foo()

will print the default value which is

def foo(x=10)

because a=10. So when you call

foo()

it will return the default value.

Try and call foo(a) on line 6. This will print the current value of a which is 5.

3.Variable scope and function definations are very simple once you master them.
As you can see.

foo()

took no value. As long as you dont give a value to

foo()

.... It will keep printing the value of first a which is 10.

Try and change the value of first a and call

foo()

without a value to see.

Hope you get the idea. happy codding :)

richieking 44 Master Poster

you need to add the sys path of pyqt to python 2.7 sys path .
Because py2.6 syspath in not the same as 2.7 syspath.(syspath is where your python got its modules and other modules installed/saved)

import sys
sys.path.append("pyqt path")## And you are set to jam!
richieking 44 Master Poster

But you can toggle the menu-underline by pressing ALT tab.

richieking 44 Master Poster

why dont you just point him to python docs!

Dont give him a fish! show him how to catch one.

You are not doing hime anygood.

richieking 44 Master Poster

In python... you can even put the output of the entire app. into a variable.
;)

richieking 44 Master Poster

You need a method/function that contain yield to yield the values. Yield will release memory after giving so there will not be any memory holding.

eg..

yield d["home"]= d1.values()

Spot on. ;)

richieking 44 Master Poster

Sorry mate but this is windows thing not wxpython.

Check this out....

Right click the Desktop/Properties/Appearance/Effects/Hide underlined
letters

And you can toggle the menu-underline by pressing ALT tab.

richieking 44 Master Poster

on line 53.... you have wx.EXPAND flat set but you have not given the permission to expand. Change to this,,,,,,,,,

sizer.Add(myEditor, 1, wx.EXPAND)

1 is the proportion/permission. so change the 0 to 1 anywhere you want to expand.
If you got more than one expand... Then you increase the proportion of the bigger control you want to .

;)

ShadyTyrant commented: Found solution +2
richieking 44 Master Poster

Here you go my friend :)

file1="".join('99 root S 5176 95 41.2 8.3 snmpd'.split()[5:6])
file2= "".join('99 root S 5176 95 1.0 8.3 snmpd'.split()[5:6])

print(float(file1)- float(file2))
## output
40.2

Hope it helps.

richieking 44 Master Poster

try this

import time
before = time.time()
print("Started time stamp"),time.ctime(before)
somme = raw_input('1 + 1 = ')
if somme.strip() == '2':
   diff = time.time() # time difference in seconds as a floating point number
   print("ended time: "),time.ctime(diff)
   print("Time diff in seconds :"),diff-before
richieking 44 Master Poster

yep...

because pyserial has included it.
example.,,,,

import serial
ser = serial.Serial (0 , baudrate = 57600 , timeout = 1) #open serial port (1) - 1
line = ser.readline() ## will get the implementation of FileList method readline() if you dont have a local readline() method define

ser.close()
richieking 44 Master Poster

def on_paint(event):
self.dc == wx.PaintDC(event.GetEventObject())
self.dc.SetPen(wx.Pen("BLACK", 4))

self.hangingman.Bind(wx.EVT_PAINT, on_paint)

There error is this method you creadted is not part of the class without the keyword self. try this.......

def on_paint(self,event):
        self.dc == wx.PaintDC(event.GetEventObject())
        self.dc.SetPen(wx.Pen("BLACK", 4))

self.hangingman.Bind(wx.EVT_PAINT, on_paint)

And here you go ;)

richieking 44 Master Poster

Very simple.

You can inherit one class into another if you need its functionality.
That is why we got import in python, #include<> in C,C++ , ...etc.

Anytime you import.... You build your class with that module's class methods but they are not native to your class. That is without the native imported class.... things will break down.

Hope you got it. :)

richieking 44 Master Poster

well said ;)

Also d is just there to show the type of variable the method can use. int,char,float ...etc.
But in python variables types are not much worried about since python takes care of that.
;)

richieking 44 Master Poster

yep snippsat.
good job ;)

richieking 44 Master Poster

Im not too familiar with http so what is the key I want to use for the values dict for that line?
topic_title? or input_text?... I dont wanna brute force it because people might get angry at like 20 test threads lol.

the Dict keys are

<input id='topic_title' class='input_text' type="text" size="50" maxlength="150" name="TopicTitle" value="" tabindex="0" /> 

url{"id":"topic_file","class":"input_text"...}

You got the idea??
:)

richieking 44 Master Poster

Better close this thread and ask your question in Django forum.
I will do that if i were you.
:)

richieking 44 Master Poster
>>> d="hello"
>>> d[0]
'h'
>>>

from idle.

richieking 44 Master Poster

Yea sorry mate. Realize is for toolbar. Is my mistake. This happends when dealing with so manythings at one time. I will run your code on windows box now.

richieking 44 Master Poster

On my Ubuntu linux Box There is nothing wrong with your code. the underline is seen.

add this line after line 24

self.SetManubar(menuBar)
menuBar.Realize()

after that.

This help on windows ok.
;)

richieking 44 Master Poster

Post that code for checkup ;)

richieking 44 Master Poster

You can upvote me a lil and close the thread
;)
thanks

richieking 44 Master Poster

As Grib said. Its always a good idea to overide and declare just after the

def __ini__()

Not only for threading but all. It will save you from pain.
Also i will like an open server binding. line 31.
with that, the server can be used any where.

Secondly, client side.
number 17-19 i personaly dont like that. Put the logic in a while loop.
Bring them under line 21.

richieking 44 Master Poster

Because text your classs for text2 is wrong.
Try this..
(text2.py)

class Text(object): ## object not very important. you can remove that.
   def text(self):
     return("Hello world")

now call text2.py class.
(text1.py)

from text2 import Text
hello = Text()
print hello.text()

##output
Hello world

Very simple. I think its well explained yea ;)

altXerror commented: thanks. this really helped me. +1
richieking 44 Master Poster

ha ha .... i was emphasizing on snippsat's explanations.

He was a good teacher. Expalined very well and i think every newbie will just understand what went on.

Hay tonyjv...
wasnt you who complained about my list comp. on the other post that newbie will not understand nd read??... ;)
Tonyjv in love at 9 ;)
Hay happy new year buddy.

richieking 44 Master Poster

concised ;)

richieking 44 Master Poster

I think besides the problem of newbie readabilty....

There is nothing major wrong with this solution.
Anyway thanks guys.
:)

richieking 44 Master Poster

Grib

You eat and drink python..!
What a man! ;)

Tcll commented: I love Grib, he's amazing! =3 +4
richieking 44 Master Poster

well then close the thread my friend
;)

richieking 44 Master Poster

You dont even need to worry about closing the file.
with does the magic.
;)

richieking 44 Master Poster
wx.TextCtrl(panel,-1,style=wx.TE_MULTILINE|wx.TE_RICH2)

wxpython will save textctrl as text format. It will keep basic formating like indentaions,spaces, etc.

But to save to doc,docx or other format. You will have to convert to that format.
;)

richieking 44 Master Poster

Well how about this then?
;)

alis="""
'site-website-20110105-101303.jpa', 'site-website-20110106-163312.jpa', 
'site-website-20110108-094822.jpa', 'site-website-20110108-095834.jpa',
 'site-website-20110109-203148.jpa', 'site-website-20110110-040326.jpa', 
 'site-www.website-20110109-040402.jpa', 'site-www.website-20110111-040219.jpa' """.split(",")

alis.sort()
info=([(x.split("-")[2:3],([z.split(".")[0] for z in x.split("-")[3:4]])) for x in alis])
richieking 44 Master Poster

mmmmmm not bad

richieking 44 Master Poster

Have you tried google?

richieking 44 Master Poster

This is possible in python my friend.

alist=["one","foo","spam","more","spam",1,5]

# to Add
alist.append("bingo")## to add to the last slot
alist.insert(3, "three")# Insert to where you wantt. eg in C alist[3]="three"

print(alist)

##Out Put
['one', 'foo', 'spam', 'three', 'more', 'spam', 1, 5, 'bingo']

Play around with python list. This is the same as array in C,C++...
Welcome!