bumsfeld 413 Nearly a Posting Virtuoso

Use information from yahoo finance and the like to create a stock ticker.

bumsfeld 413 Nearly a Posting Virtuoso

Barbecued chicken, corn and a fifth of July.

bumsfeld 413 Nearly a Posting Virtuoso

Time wounds all heals.

bumsfeld 413 Nearly a Posting Virtuoso

Typical greasy hamburger with all the junk on it, and diet coke to drink.

bumsfeld 413 Nearly a Posting Virtuoso

Something like this should work:

# check for password entry, close application if not correct

import wx

class MyClass(wx.Frame):

    def __init__(self, parent=None, id=-1):
        wx.Frame.__init__(self, parent, id, 'Password Program', size=(300,300))
        panel = wx.Panel(self)
        
        box = wx.TextEntryDialog(None, 'Please type your password:','Password')
        if box.ShowModal() == wx.ID_OK:
            answer = box.GetValue()
        # check password, you want ot use 'rot13' to mask password
        if answer != 'password':
            # message to user
            self.SetTitle('%s is incorrect password!' % answer)
            # wait 3 seconds, then close the app
            # or call dialog box again
            wx.FutureCall(3000, self.Destroy)
        # here goes the code to go on ...
        
        
if __name__=='__main__':
    app = wx.App(0)
    frame = MyClass()
    frame.Show()
    app.MainLoop()
bumsfeld 413 Nearly a Posting Virtuoso

The tiny 'water boatman' insect is the world's loudest animal relative to its body size.

bumsfeld 413 Nearly a Posting Virtuoso
s = 'abcdefg'

print(s[-2:])
print(s[:-2])
print(s[::-2])
bumsfeld 413 Nearly a Posting Virtuoso

When your girlfriend thinks you are one computer genius.

bumsfeld 413 Nearly a Posting Virtuoso

Malacca sweet rum on ice.

bumsfeld 413 Nearly a Posting Virtuoso

Tomorrow is another day.

bumsfeld 413 Nearly a Posting Virtuoso

Chicken apple salad with white wine.

bumsfeld 413 Nearly a Posting Virtuoso

I shower with the stuff.

Ancient Dragon commented: LOL +0
bumsfeld 413 Nearly a Posting Virtuoso

Looks like you are really lacking the fundamentals of Python.

bumsfeld 413 Nearly a Posting Virtuoso

I would recommend Python 2.7 for you to learn. It does have elements of Python 3 in it as options.

bumsfeld 413 Nearly a Posting Virtuoso

Portugal, Italy, Ireland, Greece and Spain — have the combined debt liability of about $616 billion. In the murky world of intertwined bank derivatives, nobody knows which bank in which country is holding those derivatives until defaults occur. Most likely the taxpayers of such a country will have to bail out the affected bank there.

bumsfeld 413 Nearly a Posting Virtuoso

Could you add some comments to your code and tell us what you are doing?

bumsfeld 413 Nearly a Posting Virtuoso

Hint ...

str_list = ['1','2.4','-5.3','7']
# use list comprehension
num_list = [float(item) for item in str_list]

print(num_list)  # [1.0, 2.4, -5.3, 7.0]
bumsfeld 413 Nearly a Posting Virtuoso

Theme: Power of the Office

AUSTIN, TX (Dec. 12, 1999) - Attorneys for Texas Governor George W. Bush filed suit in federal court today, seeking to prevent Santa Claus from making his list then checking it twice. The complaint seeks an immediate injunction against the beloved Christmas icon, asking the court to effectively ban his traditional practice of checking the list of good boys and girls one additional time before packing his sleigh.

The suit, filed in the Federal District Court of Austin, Texas, asks Federal Judge T. Grinch to "hereby order Mr. Clause to cease and desist all repetitive and duplicative list-checking activity, and certify the original list as submitted, without amendment, alteration, deletion, or other unnecessary modification."

"There are no standards for deciding who is naughty, and who is nice. It's totally arbitrary and capricious. How many more times does he need to check? This checking, checking, and re-checking over and over again must stop now," said former secretary James Baker.

Baker further claimed that unnamed GOP observers witnessed an elf remove all boys named Justin from the 'nice' list, filing them under 'naughty' instead because "everyone knows all boys named Justin are brats."

Governor Bush cited the potential for unauthorized list tampering, and blasted what he calls the "crazy, crazy mess up there at the North Pole."

"Their security is really awful, really bad," said Bush. "My mother just walked right in, told 'em she was Mrs. Claus. They didn't check …

bumsfeld 413 Nearly a Posting Virtuoso
# test PySide widgets
# get widget's size

from PySide.QtCore import *
from PySide.QtGui import *

app = QApplication([])

# ----- start your widget test code ----

label = 'x'*20
button = QPushButton(label)
width = button.sizeHint().width()
height = button.sizeHint().height()

button.show()

print("button width=%d  height=%d (in pixels)" % (width, height))

# ---- end of widget test code -----

app.exec_()
bumsfeld 413 Nearly a Posting Virtuoso

Sorry!

bumsfeld 413 Nearly a Posting Virtuoso
bumsfeld 413 Nearly a Posting Virtuoso

Don't forget the famous British sports car, the Jaguar.

bumsfeld 413 Nearly a Posting Virtuoso

Leg of giant chicken and grilled dogs, glass of dandelion wine.

bumsfeld 413 Nearly a Posting Virtuoso

6+2x10 is easy
but
I oftened wondered what 7+2x10 could be

Very funny for someone from LA!
We could make that into one good movie to beat 'Dumb and Dimmer'.

bumsfeld 413 Nearly a Posting Virtuoso

Sure, God talked out of a burning bush to the writers of the Bible. They had His guidance.

bumsfeld 413 Nearly a Posting Virtuoso

They sold hair dye that caused cancer, die from dye, ironic!

bumsfeld 413 Nearly a Posting Virtuoso

In the movie "Dukes of Hazard" 30 Dodge Charger 1969 R/T's where Destroyed in the production.

Isn't that depressing.

Not to count all those equally nice sheriff cars.

bumsfeld 413 Nearly a Posting Virtuoso

Now here is true English sports car, dream of many college students.

bumsfeld 413 Nearly a Posting Virtuoso

Sports car is something you drive, it doesn't drive you like most of the old US heavy clunkers did.

bumsfeld 413 Nearly a Posting Virtuoso

I think I remember you.

bumsfeld 413 Nearly a Posting Virtuoso

Just simple salad with tomato and some Mozzarella cheese, with nice balsamic vinaigrette. To drink, red wine of course.

bumsfeld 413 Nearly a Posting Virtuoso

Pyside is the open source PyQT GUI toolkit and follows PyQT code pretty well. If you want to explore the large number of widgets, here is one simple widget tester:

# very simple template to test PySide widgets
# used the Windows self-extracting installer
# PySide-1.0.0qt472.win32-py2.7.exe
# from:
# http://developer.qt.nokia.com/wiki/PySide_Binaries_Windows

from PySide.QtCore import *
from PySide.QtGui import *

app = QApplication([])  # no need to import sys

# ----- put your widget code here ----- 

frame = QFrame()
frame.setLineWidth(3)

# test different styles
#frame.setFrameStyle(QFrame.Box|QFrame.Sunken)
# or
frame.setFrameStyle(QFrame.Box|QFrame.Raised)

frame.show()

# ----- end of widget code -----

app.exec_()
vegaseat commented: helpful stuff +15
bumsfeld 413 Nearly a Posting Virtuoso

I think woooee's approach is clearer. The extra close() may be too easy to miss.

bumsfeld 413 Nearly a Posting Virtuoso

If you have Python 2.7 or higher, vegaseat's approach can be simplified:

# with Python27+ you can use the following scheme for padding
# binary numbers with leading zeros

print(bin(255))                     # 0b11111111
print(bin(255)[2:])                 # 11111111
print(bin(255)[2:].rjust(12, '0'))  # 000011111111

print(bin(76)[2:].rjust(8, '0'))    # 01001100

Or putting it all into one nice function:

def int2binpad(num, bits=4):
    """
    returns the binary of integer num, using bits
    number of digits, will pad with leading zeros
    needs Python27 or higher
    """
    return bin(num)[2:].rjust(bits, '0')

# test
print(int2binpad(255, 12))  # 000011111111
print(int2binpad(254, 12))  # 000011111110
print(int2binpad(76, 8))    # 01001100
print(int2binpad(3))        # 0011

# stressing the function one little, seems to behave
print(int2binpad(76))       # 1001100
bumsfeld 413 Nearly a Posting Virtuoso

I am experimenting with overlapping transparent images using wxPython. Here is something I came up with (used one of vegaseat's images):

# use wx.Image() to create two overlapping transparent images

import wx

class ImagePanel(wx.Panel):

    def __init__(self, parent):
        wx.Panel.__init__(self, parent, wx.ID_ANY)

        self.parent = parent
        # pick 2 image files you have in the working folder
        # (or give the full path)
        image_file1 = 'Duck_right.jpg'
        image_file2 = 'Duck_left.jpg'
        # default is type=wx.BITMAP_TYPE_ANY
        self.image1 = wx.Image(image_file1)
        self.image2 = wx.Image(image_file2)
        # need this ...
        self.image1.InitAlpha()
        self.image2.InitAlpha()
        # call on_paint() to create the canvas
        wx.EVT_PAINT(self, self.on_paint)

    def on_paint(self, event):
        dc = wx.PaintDC(self)
        # reduces flicker
        #dc = wx.BufferedDC(dc)
        # set the canvas background color to a light grey
        dc.SetBackground(wx.Brush("#D0D0D0"))
        #dc.SetBackground(wx.Brush("white"))  # if you like
        dc.Clear()

        # adjust r g b and alpha (transparency) of image
        # AdjustChannels(fr, fg, fb, fa)
        # adjust alphas from 0.0 to 1.0 to see the effects
        alpha1 = 0.5
        alpha2 = 0.7
        if self.image1.HasAlpha(): 
            image1 = self.image1.AdjustChannels(1.0, 1.0, 1.0, alpha1)
            image2 = self.image2.AdjustChannels(1.0, 1.0, 1.0, alpha2)
        else:
            image1 = self.image1
            image2 = self.image2
            self.parent.SetTitle("no alpha")

        # required to draw images on canvas
        bmp1 = wx.BitmapFromImage(image1)
        bmp2 = wx.BitmapFromImage(image2)
        # now draw the images
        dc.DrawBitmap(bmp2, 180, 10, True)
        dc.DrawBitmap(bmp1, 20, 70, True)
        

app = wx.App(0)
mytitle = "wx.Image transparent overlapping images"
mysize = (500, 400)
frame = wx.Frame(None, wx.ID_ANY, title=mytitle, size=mysize)
ImagePanel(frame)
frame.Show(True)
app.MainLoop()
bumsfeld 413 Nearly a Posting Virtuoso

Show us one code example you have tried.

For typical class inheritance see:
http://www.daniweb.com/software-development/python/threads/20774/273770#post273770

e-papa commented: Good answer +3
bumsfeld 413 Nearly a Posting Virtuoso
# the Tkinter filedialog for saving file
# tkfd.asksaveasfile(**options) returns file handle to save to

try:
    # Python2
    import Tkinter as tk
    import tkFileDialog as tkfd
except ImportError:
    # Python3
    import tkinter as tk
    import tkinter.filedialog as tkfd

mask = [
    ("Text files","*.txt"),
    ("Python files","*.py *.pyw"),
    ("All files","*.*")]

# if the filename does not have extension
# it will add the specified defaultextension
file_save = "test77"
fout = tkfd.asksaveasfile(
    title="testing defaultextension='.txt'",
    initialdir="C:/Python27/Atest27/Bull",
    initialfile=file_save,
    defaultextension=".txt",
    filetypes=mask)

# test write a file
data = """\
1
2
3
4
"""
fout.write(data)
fout.close()
HiHe commented: helpful stuff +4
Gribouillis commented: good post +14
bumsfeld 413 Nearly a Posting Virtuoso

Properly trained, any man can be dog's best friend.

bumsfeld 413 Nearly a Posting Virtuoso

"We can judge the heart of a man by his treatment of animals."
--- Immanuel Kant

bumsfeld 413 Nearly a Posting Virtuoso

... when you get lots of hearing aid advertisements in the mail.

bumsfeld 413 Nearly a Posting Virtuoso

You can expand on that:

# safe numeric input function
# all() needs Python25 or higher

def input_num(prompt="Enter number: "):
    """
    prompt the user for numeric input
    prompt again if the input is not numeric
    return integer or float
    """
    while True:
        # coded for Python3, Python2 uses raw_input()
        # strip() removes any leading or trailing whitespace
        num_str = input(prompt).strip()
        # make sure that all char are of typical number
        if all(c in '+-.0123456789' for c in num_str):
            break
    # float contains period (US)
    if '.' in num_str:
        return float(num_str)
    else:
        return int(num_str)

# testing ...
n = input_num()
print( n, type(n) )
bumsfeld 413 Nearly a Posting Virtuoso

Irish Soda Bread and one cup of mint tea

bumsfeld 413 Nearly a Posting Virtuoso

One short frequency test to check your hearing and age:
http://www.youtube.com/watch?v=kz5VdpUVeuM

bumsfeld 413 Nearly a Posting Virtuoso

A extraordinarily strong solar wind could strip the Earth's atmosphere, this way only life forms that don't use oxygen will survive.

bumsfeld 413 Nearly a Posting Virtuoso

Here is a typical example that might work for you:

# using Tkinter's Optionmenu() as a combobox
# allows one item to be selected
# use trace() and globalgetvar(name) to show selected choice

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

def show_choice(name, index, mode):
    sf = "value is %s" % root.globalgetvar(name)
    root.title(sf)


root = tk.Tk()

choices = ['red', 'green', 'blue', 'yellow','white']
color = tk.StringVar(root)
color.trace('w', show_choice)
# optionally preselect a choice
color.set(choices[2])
color_option = tk.OptionMenu(root, color, *choices)
color_option.pack(padx=70, pady=10)

root.mainloop()
bumsfeld 413 Nearly a Posting Virtuoso

Road Runner vs Wile E. Coyote

http://www.youtube.com/watch?v=hz65AOjabtM

bumsfeld 413 Nearly a Posting Virtuoso

You mean there is only one sun?

bumsfeld 413 Nearly a Posting Virtuoso

Good for the high protein diet I am on!

bumsfeld 413 Nearly a Posting Virtuoso

A penny saved is 1.3 pennies earned.

bumsfeld 413 Nearly a Posting Virtuoso

Judge the rest of the day by the way the eggs crack in the morning.