Dev Shed Forums - Python Programming http://forums.devshed.com/ Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language. en Tue, 21 May 2019 22:04:19 GMT vBulletin 60 http://forums.devshed.com/images/misc/rss.png Dev Shed Forums - Python Programming http://forums.devshed.com/ baffled http://forums.devshed.com/python-programming/981493-baffled-new-post.html Tue, 14 May 2019 14:54:56 GMT Class c draws a grid a window. When the tile size is 8 it draws as I expect. When the tile size is greater than 8, in an integral way, some of the lines don't show.
Fails on linux with one release of python3, fails on windows with a different python3 release, and as I recall in a different way.

I'd like to use a tile size larger than 8 because my eyesight isn't so good. Something like a tile_size pixel font is going into the grid in the finished program.

Thanks, Dave.

With tile_size of 20 or so the clipped, vanished, undrawn lines are quite obvious.
Code:

#! python3
import tkinter

border_size = 9

class c:

    def __init__(self, root = None, tile_size = 9, title = 'fail'):
        if root == None:
            root = tkinter.Tk()
            size = '{}x{}'.format(* 2 * (27 * tile_size + 4 * border_size,))
            print(size)
            root.wm_geometry(size)
            root.wm_title(title)
        self.root = root
        c = self.canvas = tkinter.Canvas(root)
        i = 3
        h = border_size // 2
        n = h + i * (border_size + 9 * tile_size)
        l = c.create_line
        for i in range(4):
            m = (border_size // 2) + i * (border_size + 9 * tile_size)
            l(m, h, m, n, fill = 'black', width = 3)
            l(h, m, n, m, fill = 'black', width = 3)
            print(h,m,n)
        c.pack()

    def update(self):
        self.root.update()

    def mainloop(self):
        self.root.mainloop()

a = c(tile_size = 9, title = 'fail with 9 or larger')
a.update()

print()

b = c(tile_size = 8, title = 'success')
b.update()

input('enter terminates')

]]>
Python Programming b49P23TIvg http://forums.devshed.com/python-programming-11/baffled-981493.html
PHP to Python http://forums.devshed.com/python-programming/981458-php-python-new-post.html Sat, 27 Apr 2019 04:18:37 GMT Hi All, I learning Python and I see that my knowledge of this language is very poor as I am trying to translate a function from PHP to Python but I cannot get results. This is the code in PHP and below, my try in Python, Code: --------- __________________ Hi All,

I learning Python and I see that my knowledge of this language is very poor as I am trying to translate a function from PHP to Python but I cannot get results.

This is the code in PHP and below, my try in Python,
Code:

__________________

PHP Code
__________________

function getCombinations($arrays) {
        $result = array(array());
        foreach ($arrays as $property => $property_values) {
                $tmp = array();
                foreach ($result as $result_item) {
                        foreach ($property_values as $property_value) {
                                $result_item[$property] = $property_value;
                                $tmp[] = $result_item;
                        }
                }
                $result = $tmp;
        }
        return $result;
}

$combinations = getCombinations(
        array(
                'item1' => array('A', 'B'),
                'item2' => array('C', 'D'),
                'item3' => array('E', 'F'),
        )
);

var_dump($combinations);
__________________

MY TRY IN PYTHON
__________________

def getCombinations(arrays):
        result = []
        for property, property_values in arrays.items():
                tmp = []
                for result_item in result:
                        for property_value in property_values:
                                result_item[property] = property_value
                                tmp.append(result_item)
                result = tmp
        return result

My intention is to learn where are my faults to continue learning.

Thanks a lot in advance.

Mapg ]]>
Python Programming mapg http://forums.devshed.com/python-programming-11/php-python-981458.html