├── LICENSE ├── README.md ├── app ├── clock.py ├── dbms.py ├── dimensions ├── engine.py ├── exit ├── frames ├── __init__.py ├── categories.py ├── category.py ├── license.py ├── main.py ├── product.py ├── supplier.py └── suppliers.py ├── info ├── log.txt ├── northwind.sl3 ├── theme ├── tkinterlite.py ├── tkinterlite.sql └── tools.py /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tkinterlite (Tkinter & Sqlite) 2 | 3 | [![Python 3](https://img.shields.io/badge/python-3%20-blue.svg)](https://www.python.org/downloads/) 4 | [![Tkinter](https://img.shields.io/badge/Tkinter%20-green.svg)](https://docs.python.org/3/library/tk.html) 5 | [![SQLite](https://img.shields.io/badge/sqlite-%2307405e.svg)](https://www.sqlite.org/index.html) 6 | 7 | How create a full GUI application with Python Sqlite and Tkinter. 8 | 9 | ![alt tag](https://user-images.githubusercontent.com/5463566/150857962-3a3f73b8-ad88-41a9-8d87-4e7524cc2808.png) 10 | 11 | Developend on Debian Release 9 (stretch) 64-bit. 12 | 13 | Spring 2017 14 | 15 | Hi all, here we are! 16 | 17 | tkinterlite, (Tkinter Sqlite) is my personal study on python 3.4.2 tkinter and sqlite, and by the way the beginning of my 18 | 19 | adventure with git-hub. 20 | 21 | To run the project, execute tkinterlite.py , something like... 22 | 23 | bc@hal9000:~/Tkinterlite-master$ python3 tkinterlite.py 24 | 25 | enjoy yourself 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /app: -------------------------------------------------------------------------------- 1 | iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1goLDgY06HK0CwAAAuNJREFUSMfNldlL1UEUx78zv9/vru5ilt5K73WJVCQSizZRCvVGUohKlOBL9BZEPURU9FIa/QVB79FCSEK9ZEVFUE8JZYHbTS1zverdfsvM/HoxMfVuFdGB8zRzzuecM9+ZAf4vM0myEQkHeLydHSal5ym37xx8ckb7q4CtjZ11iiI9zslOozOzgbchM1Rv4dbQyj1UJxnDTy8srI6l8ZK7vV0Vkiw9Ot5cYz3dXq+UlLiqnDTlOQBcOtuCK+faIEk0akcxAUWNN1xEps+ONOxy5OVmwzcVwrGGatv2bVsqAUCRJUg09hDkqJUf7Eo3FfJi3+7yjLJiFxn8HgDjJkanTTQdqrLmZqWACzPujNfvoOWeJDml7sqygvwD1aXyyFQQjJsAgKDKMDQZhLuoECNTIZhxAOt2UKz7bm/Oy6mur9lhG5pYRDDCflk3DIZASAOlBJzbwbmwEhspANC3Ope0Ro5NNy9npKeeaju6xzk+G8ZcUAMXYl1nXCDdoSAtLUX4RidbMz213f6B3tmoMi30Xm+32W23Otrq7Isqw4Q/ElfCFpmiND8d/QNfRe/LvnkBttfXc/Hzmg62NnbWSRb5zonm/Xan04ZPY/6ola90nXHMBlRUFucSq81qHRubOZnqqe1ZGOydXj5kt7erghD0coPb7z58BVVjYEzAMHhCHlEZVI3h9ZsPlHOeSQn56Dl8rXz5kFVJHZKFNQsAwqoxp+kGGGPgwkzoOZAoQURnMBiHIMgCgIhh0ZcB33quhgGEAaDA27m0OXGAoAQRzQAAc9ThWcT9Vh5TphFVh24kDgAAXWcglOhu/3DKMLAQG6AZ0A0GkQQgrOmJX7SQqkNnyQKMJdWbMQGbAEDTOTgTEGbiAFVjgGnS6f4HGxFlRBkAXADAhMCGTEdSH4fBOAgFjPB0HoBJAPOrAeRnnvfv+n/3T1UUZ7ZTnf9CohXmAuCI9YzHMbYk9/FYnRP8mZn4l/YD7TuA32k81GAAAAAASUVORK5CYII= 2 | -------------------------------------------------------------------------------- /clock.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | #----------------------------------------------------------------------------- 3 | # project: tkinterlite 4 | # authors: 1966bc 5 | # mailto: [giuseppecostanzi@gmail.com] 6 | # modify: hiems MMXXI 7 | #------------------------------------------------------------------------------ 8 | """ This is the clock module of Tkinterlite.""" 9 | import threading 10 | import queue 11 | import datetime 12 | import time 13 | 14 | 15 | class Clock(threading.Thread): 16 | def __init__(self): 17 | threading.Thread.__init__(self) 18 | 19 | self.queue = queue.Queue() 20 | self.check = True 21 | 22 | def stop(self): 23 | self.check = False 24 | 25 | def run(self): 26 | 27 | """Feeds the tail.""" 28 | 29 | while self.check: 30 | s = "Astral date: " 31 | t = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") 32 | msg = "{0} {1}".format(s, t) 33 | time.sleep(1) 34 | self.queue.put(msg) 35 | 36 | def check_queue(self, obj): 37 | 38 | """Returns a formatted string representing time.""" 39 | 40 | while self.queue.qsize(): 41 | try: 42 | x = self.queue.get(0) 43 | msg = "{0}".format(x) 44 | obj.set(msg) 45 | except queue.Empty: 46 | pass 47 | -------------------------------------------------------------------------------- /dbms.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | #----------------------------------------------------------------------------- 3 | # project: tkinterlite 4 | # authors: 1966bc 5 | # mailto: [giuseppecostanzi@gmail.com] 6 | # modify: hiems MMXX 7 | #----------------------------------------------------------------------------- 8 | import sys 9 | import inspect 10 | import datetime 11 | import sqlite3 as lite 12 | 13 | class DBMS: 14 | def __init__(self,): 15 | self.set_connection() 16 | #super().__init__() 17 | 18 | def __str__(self): 19 | return "class: {0}\nMRO: {1}".format(self.__class__.__name__, 20 | [x.__name__ for x in DBMS.__mro__],) 21 | 22 | def set_connection(self): 23 | 24 | self.con = lite.connect("northwind.sl3", 25 | detect_types=lite.PARSE_DECLTYPES|lite.PARSE_COLNAMES, 26 | isolation_level='IMMEDIATE') 27 | self.con.text_factory = lite.OptimizedUnicode 28 | 29 | 30 | def read(self, fetch, sql, args=()): 31 | 32 | """Remember that fetchall() return a list.\ 33 | An empty list is returned when no rows are available. 34 | Testing if the list is empty with 'if rs' or 'if not rs' 35 | Otherwise fetchone() return a single sequence, or None 36 | when no more data is available. 37 | Testing as 'if rs is not None'. 38 | """ 39 | 40 | try: 41 | cur = self.con.cursor() 42 | cur.execute(sql, args) 43 | 44 | if fetch == True: 45 | rs = cur.fetchall() 46 | else: 47 | rs = cur.fetchone() 48 | cur.close() 49 | return rs 50 | 51 | except: 52 | self.on_log(self, 53 | inspect.stack()[0][3], 54 | sys.exc_info()[1], 55 | sys.exc_info()[0], 56 | sys.modules[__name__]) 57 | 58 | def write(self, sql, args=()): 59 | 60 | try: 61 | cur = self.con.cursor() 62 | cur.execute(sql, args) 63 | self.con.commit() 64 | return cur.lastrowid 65 | 66 | except: 67 | self.con.rollback() 68 | self.on_log(self, 69 | inspect.stack()[0][3], 70 | sys.exc_info()[1], 71 | sys.exc_info()[0], 72 | sys.modules[__name__]) 73 | 74 | finally: 75 | try: 76 | cur.close() 77 | except: 78 | self.on_log(self, 79 | inspect.stack()[0][3], 80 | sys.exc_info()[1], 81 | sys.exc_info()[0], 82 | sys.modules[__name__]) 83 | 84 | def dump(self,): 85 | 86 | dt = datetime.datetime.now().strftime("%Y%m%d%H%M%S") 87 | s = dt + ".sql" 88 | with open(s, 'w') as f: 89 | for line in self.con.iterdump(): 90 | f.write('%s\n' % line) 91 | 92 | def get_fields(self, table): 93 | """return fields name of the args table ordered by field number 94 | 95 | @param name: table, 96 | @return: fields 97 | @rtype: tuple 98 | """ 99 | try: 100 | 101 | columns = [] 102 | fields = [] 103 | sql = "SELECT * FROM {0}".format(table) 104 | cur = self.con.cursor() 105 | cur.execute(sql) 106 | 107 | for field in cur.description: 108 | columns.append(field[0]) 109 | cur.close() 110 | 111 | for k, v in enumerate(columns): 112 | if k > 0: 113 | fields.append(v) 114 | 115 | return tuple(fields) 116 | except: 117 | self.on_log(self, 118 | inspect.stack()[0][3], 119 | sys.exc_info()[1], 120 | sys.exc_info()[0], 121 | sys.modules[__name__]) 122 | finally: 123 | try: 124 | cur.close() 125 | except: 126 | self.on_log(self, 127 | inspect.stack()[0][3], 128 | sys.exc_info()[1], 129 | sys.exc_info()[0], 130 | sys.modules[__name__]) 131 | 132 | 133 | def get_update_sql(self, table, pk): 134 | """recive a table name and his pk to format an update sql statement 135 | 136 | @param name: table, pk 137 | @return: sql formatted stringstring 138 | @rtype: string 139 | """ 140 | return "UPDATE {0} SET {1} =? WHERE {2} =?".format(table, " =?, ".join(self.get_fields(table)), pk) 141 | 142 | def get_insert_sql(self, table, n): 143 | """recive a table name and len of args, len(args), 144 | to format an insert sql statement 145 | 146 | @param name: table, n = len(args) 147 | @return: sql formatted stringstring 148 | @rtype: string 149 | """ 150 | 151 | return "INSERT INTO {0}({1})VALUES({2})".format(table, ",".join(self.get_fields(table)), ",".join("?"*n)) 152 | 153 | 154 | def get_selected(self, table, field, *args): 155 | """recive table name, pk and return a dictionary 156 | 157 | @param name: table,field,*args 158 | @return: dictionary 159 | @rtype: dictionary 160 | """ 161 | 162 | d = {} 163 | sql = "SELECT * FROM {0} WHERE {1} = ?".format(table, field) 164 | 165 | for k, v in enumerate(self.read(False, sql, args)): 166 | d[k] = v 167 | 168 | return d 169 | 170 | 171 | def main(): 172 | 173 | foo = DBMS() 174 | print(foo) 175 | 176 | sql = "SELECT name FROM sqlite_master WHERE type = 'table'" 177 | rs = foo.read(True, sql) 178 | if rs: 179 | for i in enumerate(rs): 180 | print(i) 181 | 182 | input('end') 183 | 184 | if __name__ == "__main__": 185 | main() 186 | -------------------------------------------------------------------------------- /dimensions: -------------------------------------------------------------------------------- 1 | w,800 2 | h,400 3 | -------------------------------------------------------------------------------- /engine.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | #----------------------------------------------------------------------------- 3 | # project: tkinterlite 4 | # authors: 1966bc 5 | # mailto: [giuseppecostanzi@gmail.com] 6 | # modify: hiems MMXXI 7 | #------------------------------------------------------------------------------ 8 | import os 9 | import sys 10 | import inspect 11 | import subprocess 12 | import datetime 13 | 14 | from dbms import DBMS 15 | from tools import Tools 16 | from clock import Clock 17 | 18 | 19 | 20 | class Engine(DBMS, Tools, Clock): 21 | def __init__(self,): 22 | super().__init__() 23 | 24 | self.no_selected = "Attention!\nNo record selected!" 25 | self.ask_to_delete = "Delete data?" 26 | self.ask_to_save = "Save data?" 27 | self.abort = "Operation aborted!" 28 | 29 | def __str__(self): 30 | return "class: {0}\nMRO:{1}".format(self.__class__.__name__, 31 | [x.__name__ for x in Engine.__mro__]) 32 | 33 | def get_clock(self,): 34 | """Instance the clock.""" 35 | return Clock() 36 | 37 | def get_python_version(self,): 38 | return "Python version:\n{0}".format(".".join(map(str, sys.version_info[:3]))) 39 | 40 | def get_file(self, file): 41 | """# return full path of the directory where program resides.""" 42 | 43 | return os.path.join(os.path.dirname(__file__), file) 44 | 45 | def open_file(self, path): 46 | """open file on linux and windows""" 47 | if os.path.exists(path): 48 | if os.name == 'posix': 49 | subprocess.call(["xdg-open", path]) 50 | else: 51 | os.startfile(path) 52 | 53 | def on_log(self, container, function, exc_value, exc_type, module): 54 | 55 | now = datetime.datetime.now() 56 | log_text = "{0}\n{1}\n{2}\n{3}\n{4}\n\n".format(now, function, exc_value, exc_type, module) 57 | log_file = open("log.txt", "a") 58 | log_file.write(log_text) 59 | log_file.close() 60 | 61 | def get_dimensions(self): 62 | 63 | try: 64 | d = {} 65 | with open("dimensions", "r") as filestream: 66 | for line in filestream: 67 | currentline = line.split(",") 68 | d[currentline[0]] = currentline[1] 69 | 70 | return d 71 | 72 | except FileNotFoundError: 73 | self.on_log(self, 74 | inspect.stack()[0][3], 75 | sys.exc_info()[1], 76 | sys.exc_info()[0], 77 | sys.modules[__name__]) 78 | 79 | def get_license(self): 80 | """get license""" 81 | try: 82 | path = self.get_file("LICENSE") 83 | f = open(path, "r") 84 | v = f.read() 85 | f.close() 86 | return v 87 | except FileNotFoundError: 88 | self.on_log(inspect.stack()[0][3], 89 | sys.exc_info()[1], 90 | sys.exc_info()[0], 91 | sys.modules[__name__]) 92 | 93 | def get_icon(self, which): 94 | 95 | try: 96 | path = self.get_file(which) 97 | f = open(path, "r") 98 | v = f.readline() 99 | f.close() 100 | return v 101 | 102 | except FileNotFoundError: 103 | self.on_log(self, 104 | inspect.stack()[0][3], 105 | sys.exc_info()[1], 106 | sys.exc_info()[0], 107 | sys.modules[__name__]) 108 | 109 | def get_log_file(self): 110 | 111 | try: 112 | path = self.get_file("log.txt") 113 | self.open_file(path) 114 | except FileNotFoundError: 115 | self.on_log(self, 116 | inspect.stack()[0][3], 117 | sys.exc_info()[1], 118 | sys.exc_info()[0], 119 | sys.modules[__name__]) 120 | 121 | def get_theme(self): 122 | 123 | try: 124 | path = self.get_file("theme") 125 | f = open(path, "r") 126 | theme = f.readline() 127 | f.close() 128 | return theme 129 | except FileNotFoundError: 130 | self.on_log(self, 131 | inspect.stack()[0][3], 132 | sys.exc_info()[1], 133 | sys.exc_info()[0], 134 | sys.modules[__name__]) 135 | 136 | def busy(self, caller): 137 | caller.config(cursor="watch") 138 | caller.update() 139 | 140 | def not_busy(self, caller): 141 | caller.config(cursor="") 142 | caller.update() 143 | 144 | 145 | def main(): 146 | #testing some stuff 147 | foo = Engine() 148 | print(foo) 149 | print(foo.set_connection()) 150 | input('end') 151 | 152 | if __name__ == "__main__": 153 | main() 154 | -------------------------------------------------------------------------------- /exit: -------------------------------------------------------------------------------- 1 | iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAO5SURBVDiNjZXPax1VFMc/996ZO/N+mKZ5TYo+QmNMhLYhpZJVC7pojLgLtCItajFYwY102RQENyFCcVP1H6iIiF25EFwli0q6aFpcNNBSXsEarPASXybv550f18X74XvJC3rgMMPM4TPfe+b8ENZa/ocJQAJO6wpggQiIW/c95gC898GlJWPM9YOoSinS6TQDA4fwPQ+AMApxXX1zeemLa0B9L9wBMMZcf+f8uxQKBarVKrVajVqthjEGYwxSSqanprly5SOkbAqu12t89c3XnwJLgGkp7wUDeJ6H1powDImiiDiOSZIEAK01Q0NDKKVQSgGQTmcYGR4GSAPbfVMB4Ps+WmuiKCJJEtq5N8bgeR6ZTAYhJEI0FQsBWns9jL5grTW+7/dAhRBIKdFa47Vy222ttIh+YNkd5DgOnufh+z6+7+N5Xse11oi+CPghm33jeyFu9VUspey4UgrHcZiYmCCOY4rFIq7r9oX+PD198fDU1PXg0SP1nRAftx5HHcXtY3f75uYmvu8zOTnZ+Wlts0mCc+tbsvn84mtXr3pKqUgqVZaOUxZQ7En8XrC1lkKhwKlTpzDGdOLCIODO/Dzjw8OMnz3r21KJ12/c8Nvvf1lY8HvAe1VnMhlmZma4e/cux48fB6Dy9Cmrc3OMzswwPDrK7soKWItQCpskDMzOIqRkn2IhROcDJ06c4NmzZ5RKJVKpFAC/XrjAkZERBn2f3dVVbBSRVCoklQoylSJ18iQIwYGK8/k81WqVhw8fks1mcZxm6OmbN7kzP49jDC8A9Y0NbKuRABpPnmDjeH9xt8FbW1vs7OyQTqfRWgOQJAlHzpzhzbU1Vs6d43A2w9HTp5EDA82OUYq4WgX6dE0bHIZhp8SklBQKBaSUjI2NkXtlnNl79/jp7Bnqm5v1Ucfxf1tbM/bfvvhbHgTurmfHcSiVSuwEO1QqZeI4Rg0eorF4jXKttvJ4Y6NmIblkrdvyF/eB23ClFFprisUi6/fX0Z4m/1KeXC5HFEUYY6iaBue3tz+plctfCnjczeg7QLTWBEHA+vo9Xh4f4/Ll9zl2bKw5/aKQMAqJ45hgdxegcTGKPgc+6wu21qKUwlrLgwf3OTQ4wIcLl8nlcriuSxyH1OoRArAWkiQmCAKABgdtkDiOkVLy/K/nCCxvvT1HKuXjum5z2IdhzwizNFv6P8HBTsAff/7OxKvN4yIsjUadhmk0gR2q6DCSxFKplKG5PfqDR46OLN/+8fZid+eJg2ZkV+q01svsWUlt+wfnpXqRmhuUSQAAAABJRU5ErkJggg== 2 | -------------------------------------------------------------------------------- /frames/__init__.py: -------------------------------------------------------------------------------- 1 | #FILE: gui/__init__.py 2 | -------------------------------------------------------------------------------- /frames/categories.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # ----------------------------------------------------------------------------- 3 | # project: tkinterlite 4 | # authors: 1966bc 5 | # mailto: [giuseppecostanzi@gmail.com] 6 | # modify: hiems MMXXI 7 | # ----------------------------------------------------------------------------- 8 | import tkinter as tk 9 | from tkinter import ttk 10 | from tkinter import messagebox 11 | import frames.category as ui 12 | 13 | SQL = "SELECT * FROM categories ORDER BY category ASC;" 14 | 15 | 16 | class UI(tk.Toplevel): 17 | def __init__(self, parent): 18 | super().__init__(name="categories") 19 | 20 | self.parent = parent 21 | self.attributes("-topmost", True) 22 | self.protocol("WM_DELETE_WINDOW", self.on_cancel) 23 | self.table = "categories" 24 | self.primary_key = "category_id" 25 | self.items = tk.IntVar() 26 | self.obj = None 27 | self.init_ui() 28 | self.nametowidget(".").engine.center_me(self) 29 | 30 | def init_ui(self): 31 | 32 | frm_main = ttk.Frame(self, style="App.TFrame") 33 | 34 | frm_left = ttk.Frame(frm_main, style="App.TFrame", padding=8) 35 | 36 | ttk.Label(frm_left, style="App.TLabel", textvariable=self.items,).pack(fill=tk.X, expand=0) 37 | 38 | sb = ttk.Scrollbar(frm_left, orient=tk.VERTICAL) 39 | self.lstItems = tk.Listbox(frm_left, yscrollcommand=sb.set,) 40 | self.lstItems.bind("<>", self.on_item_selected) 41 | self.lstItems.bind("", self.on_item_activated) 42 | sb.config(command=self.lstItems.yview) 43 | self.lstItems.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) 44 | sb.pack(fill=tk.Y, expand=1) 45 | 46 | frm_right = ttk.Frame(frm_main, style="App.TFrame", padding=4) 47 | 48 | bts = (("Add", 0, self.on_add, ""), 49 | ("Edit", 0, self.on_item_activated, ""), 50 | ("Close", 0, self.on_cancel, "")) 51 | 52 | for btn in bts: 53 | ttk.Button(frm_right, 54 | style="App.TButton", 55 | text=btn[0], 56 | underline=btn[1], 57 | command=btn[2],).pack(fill=tk.X, padx=5, pady=5) 58 | self.bind(btn[3], btn[2]) 59 | 60 | frm_main.pack(fill=tk.BOTH, expand=1) 61 | frm_left.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) 62 | frm_right.pack(side=tk.RIGHT, fill=tk.Y, expand=0) 63 | 64 | def on_open(self,): 65 | 66 | msg = "{0}".format(self.winfo_name().title()) 67 | self.title(msg) 68 | self.set_values() 69 | 70 | def set_values(self): 71 | 72 | self.lstItems.delete(0, tk.END) 73 | index = 0 74 | self.dict_items = {} 75 | 76 | rs = self.nametowidget(".").engine.read(True, SQL, ()) 77 | 78 | if rs: 79 | for i in rs: 80 | s = "{:}".format(i[1]) 81 | self.lstItems.insert(tk.END, s) 82 | if i[3] != 1: 83 | self.lstItems.itemconfig(index, {"bg": "light gray"}) 84 | self.dict_items[index] = i[0] 85 | index += 1 86 | 87 | msg = ("Items: {0}".format(self.lstItems.size())) 88 | self.items.set(msg) 89 | 90 | def on_add(self, evt=None): 91 | 92 | self.obj = ui.UI(self) 93 | self.obj.on_open() 94 | 95 | def on_item_selected(self, evt=None): 96 | 97 | if self.lstItems.curselection(): 98 | index = self.lstItems.curselection()[0] 99 | pk = self.dict_items.get(index) 100 | self.selected_item = self.nametowidget(".").engine.get_selected(self.table, 101 | self.primary_key, 102 | pk) 103 | 104 | def on_item_activated(self, evt=None): 105 | 106 | if self.lstItems.curselection(): 107 | index = self.lstItems.curselection()[0] 108 | self.obj = ui.UI(self, index) 109 | self.obj.on_open() 110 | 111 | else: 112 | messagebox.showwarning(self.nametowidget(".").title(), 113 | self.nametowidget(".").engine.no_selected, 114 | parent=self) 115 | 116 | def on_cancel(self, evt=None): 117 | if self.obj is not None: 118 | self.obj.destroy() 119 | self.destroy() 120 | -------------------------------------------------------------------------------- /frames/category.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # ----------------------------------------------------------------------------- 3 | # project: tkinterlite 4 | # authors: 1966bc 5 | # mailto: [giuseppecostanzi@gmail.com] 6 | # modify: hiems MMXXI 7 | # ----------------------------------------------------------------------------- 8 | import tkinter as tk 9 | from tkinter import ttk 10 | from tkinter import messagebox 11 | 12 | 13 | class UI(tk.Toplevel): 14 | def __init__(self, parent, index=None): 15 | super().__init__(name="category") 16 | 17 | self.parent = parent 18 | self.index = index 19 | self.transient(parent) 20 | self.resizable(0, 0) 21 | self.columnconfigure(0, weight=1) 22 | self.columnconfigure(1, weight=2) 23 | self.columnconfigure(2, weight=1) 24 | 25 | self.category = tk.StringVar() 26 | self.description = tk.StringVar() 27 | self.enable = tk.BooleanVar() 28 | 29 | self.init_ui() 30 | self.nametowidget(".").engine.center_me(self) 31 | 32 | def init_ui(self): 33 | 34 | paddings = {"padx": 5, "pady": 5} 35 | 36 | self.frm_main = ttk.Frame(self, style="App.TFrame") 37 | self.frm_main.grid(row=0, column=0) 38 | 39 | frm_left = ttk.Frame(self.frm_main, style="App.TFrame") 40 | frm_left.grid(row=0, column=0, sticky=tk.NS, **paddings) 41 | 42 | r = 0 43 | c = 1 44 | ttk.Label(frm_left, style="App.TLabel", text="Category:",).grid(row=r, sticky=tk.W) 45 | self.txtCategory = ttk.Entry(frm_left, textvariable=self.category) 46 | self.txtCategory.grid(row=r, column=c, sticky=tk.EW, **paddings) 47 | 48 | r += 1 49 | ttk.Label(frm_left, style="App.TLabel", text="Description:").grid(row=r, sticky=tk.W) 50 | ent_description = ttk.Entry(frm_left, textvariable=self.description) 51 | ent_description.grid(row=r, column=c, sticky=tk.EW, **paddings) 52 | 53 | r += 1 54 | ttk.Label(frm_left, style="App.TLabel", text="Enable:").grid(row=r, sticky=tk.W) 55 | chk_enable = ttk.Checkbutton(frm_left, onvalue=1, offvalue=0, variable=self.enable,) 56 | chk_enable.grid(row=r, column=c, sticky=tk.W) 57 | 58 | frm_right = ttk.Frame(self.frm_main, style="App.TFrame") 59 | frm_right.grid(row=0, column=1, sticky=tk.NS, **paddings) 60 | 61 | r = 0 62 | c = 0 63 | btn_save = ttk.Button(frm_right, style="App.TButton", text="Save", underline=0, command=self.on_save,) 64 | self.bind("", self.on_save) 65 | btn_save.grid(row=r, column=c, sticky=tk.EW, **paddings) 66 | 67 | r += 1 68 | btn_cancel = ttk.Button(frm_right, style="App.TButton", text="Cancel", underline=0, command=self.on_cancel) 69 | self.bind("", self.on_cancel) 70 | btn_cancel.grid(row=r, column=c, sticky=tk.EW, **paddings) 71 | 72 | def on_open(self): 73 | 74 | if self.index is not None: 75 | msg = "Edit {0}".format(self.winfo_name().title()) 76 | self.set_values() 77 | else: 78 | msg = "Add {0}".format(self.winfo_name().title()) 79 | self.enable.set(1) 80 | 81 | self.title(msg) 82 | self.txtCategory.focus() 83 | 84 | def set_values(self,): 85 | 86 | self.category.set(self.parent.selected_item[1]) 87 | self.description.set(self.parent.selected_item[2]) 88 | self.enable.set(self.parent.selected_item[3]) 89 | 90 | def get_values(self,): 91 | 92 | return [self.category.get(), 93 | self.description.get(), 94 | self.enable.get()] 95 | 96 | def on_save(self, evt=None): 97 | 98 | if self.nametowidget(".").engine.on_fields_control(self.frm_main, self.nametowidget(".").title()) == False: return 99 | 100 | if messagebox.askyesno(self.nametowidget(".").title(), 101 | self.nametowidget(".").engine.ask_to_save, 102 | parent=self) == True: 103 | 104 | args = self.get_values() 105 | 106 | if self.index is not None: 107 | 108 | sql = self.nametowidget(".").engine.get_update_sql(self.parent.table, self.parent.primary_key) 109 | 110 | args.append(self.parent.selected_item[0]) 111 | 112 | else: 113 | 114 | sql = self.nametowidget(".").engine.get_insert_sql(self.parent.table, len(args)) 115 | 116 | last_id = self.nametowidget(".").engine.write(sql, args) 117 | self.parent.on_open() 118 | 119 | if self.index is not None: 120 | self.parent.lstItems.see(self.index) 121 | self.parent.lstItems.selection_set(self.index) 122 | else: 123 | #force focus on listbox 124 | idx = list(self.parent.dict_items.keys())[list(self.parent.dict_items.values()).index(last_id)] 125 | self.parent.lstItems.selection_set(idx) 126 | self.parent.lstItems.see(idx) 127 | 128 | self.on_cancel() 129 | 130 | else: 131 | messagebox.showinfo(self.nametowidget(".").title(), 132 | self.nametowidget(".").engine.abort, 133 | parent=self) 134 | 135 | def on_cancel(self, evt=None): 136 | self.destroy() 137 | -------------------------------------------------------------------------------- /frames/license.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # ----------------------------------------------------------------------------- 3 | # project: tkinterlite 4 | # authors: 1966bc 5 | # mailto: [giuseppecostanzi@gmail.com] 6 | # modify: hiems MMXX 7 | # ----------------------------------------------------------------------------- 8 | import tkinter as tk 9 | from tkinter import ttk 10 | from tkinter.scrolledtext import ScrolledText 11 | 12 | 13 | class UI(tk.Toplevel): 14 | def __init__(self, parent): 15 | super().__init__(name="license") 16 | 17 | self.parent = parent 18 | self.init_ui() 19 | self.nametowidget(".").engine.center_me(self) 20 | 21 | def init_ui(self): 22 | 23 | 24 | f0 = ttk.Frame(self, 25 | style="App.TFrame", 26 | relief=tk.GROOVE, 27 | borderwidth=1, 28 | padding=8) 29 | 30 | self.txLicense = ScrolledText(f0, 31 | wrap=tk.WORD, 32 | bg="light yellow", 33 | relief=tk.GROOVE, 34 | font='TkFixedFont',) 35 | self.txLicense.pack(fill=tk.BOTH, expand=1) 36 | 37 | f0.pack(fill=tk.BOTH, padx=5, pady=5, expand=1) 38 | 39 | def on_open(self): 40 | 41 | msg = self.nametowidget(".").engine.get_license() 42 | 43 | if msg: 44 | self.txLicense.insert("1.0", msg) 45 | 46 | self.title(self.nametowidget(".").title()) 47 | -------------------------------------------------------------------------------- /frames/main.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # ----------------------------------------------------------------------------- 3 | # project: Tkinterlite 4 | # authors: 1966bc 5 | # mailto: [giuseppecostanzi@gmail.com] 6 | # modify: hiems MMXXI 7 | # ----------------------------------------------------------------------------- 8 | """ This is the main module of Tkinterlite.""" 9 | import sys 10 | import tkinter as tk 11 | from tkinter import messagebox 12 | from tkinter import ttk 13 | 14 | import frames.license 15 | import frames.product 16 | import frames.categories 17 | import frames.suppliers 18 | 19 | from engine import Engine 20 | 21 | __author__ = "1966bc" 22 | __copyright__ = "Copyleft" 23 | __credits__ = ["hal9000", ] 24 | __license__ = "GNU GPL Version 3, 29 June 2007" 25 | __version__ = "42" 26 | __maintainer__ = "1966bc" 27 | __email__ = "giuseppecostanzi@gmail.com" 28 | __date__ = "hiems MMXXI" 29 | __status__ = "production" 30 | 31 | 32 | class Main(ttk.Frame): 33 | def __init__(self, parent): 34 | super().__init__() 35 | 36 | self.parent = parent 37 | self.table = "products" 38 | self.primary_key = "product_id" 39 | self.option_id = tk.IntVar() 40 | #self.selected_item = None 41 | self.dict_combo_values = {} 42 | self.status_bar_text = tk.StringVar() 43 | self.init_menu() 44 | self.init_toolbar() 45 | self.init_status_bar() 46 | self.init_ui() 47 | self.center_ui() 48 | 49 | def init_menu(self): 50 | 51 | m_main = tk.Menu(self, bd=1) 52 | 53 | m_file = tk.Menu(m_main, tearoff=0, bd=1) 54 | m_tools = tk.Menu(m_main, tearoff=0, bd=1) 55 | s_databases = tk.Menu(m_file) 56 | m_about = tk.Menu(m_main, tearoff=0, bd=1) 57 | 58 | items = (("File", m_file), 59 | ("Tools", m_tools), 60 | ("?", m_about),) 61 | 62 | for i in items: 63 | m_main.add_cascade(label=i[0], underline=0, menu=i[1]) 64 | 65 | m_file.add_cascade(label="Database", menu=s_databases, underline=0) 66 | 67 | items = (("Dump", self.on_dump), 68 | ("Vacuum", self.on_vacuum),) 69 | 70 | for i in items: 71 | s_databases.add_command(label=i[0], underline=0, command=i[1]) 72 | 73 | m_file.add_command(label="Log", underline=1, command=self.on_log) 74 | m_file.add_separator() 75 | 76 | m_file.add_command(label="Exit", underline=0, command=self.parent.on_exit) 77 | 78 | items = (("Categories", self.on_categories), 79 | ("Suppliers", self.on_suppliers),) 80 | 81 | for i in items: 82 | m_tools.add_command(label=i[0], underline=0, command=i[1]) 83 | 84 | items = (("About", self.on_about), 85 | ("License", self.on_license), 86 | ("Python", self.on_python_version), 87 | ("Tkinter", self.on_tkinter_version),) 88 | 89 | for i in items: 90 | m_about.add_command(label=i[0], underline=0, command=i[1]) 91 | 92 | for i in (m_main, m_file, s_databases, m_tools, m_about): 93 | i.config(bg=self.nametowidget(".").engine.get_rgb(240, 240, 237),) 94 | i.config(fg="black") 95 | 96 | self.nametowidget(".").config(menu=m_main) 97 | 98 | def init_toolbar(self): 99 | 100 | toolbar = tk.Frame(self, bd=1, relief=tk.RAISED) 101 | 102 | img_exit = tk.PhotoImage(data=self.nametowidget(".").engine.get_icon("exit")) 103 | img_info = tk.PhotoImage(data=self.nametowidget(".").engine.get_icon("info")) 104 | 105 | exitButton = tk.Button(toolbar, width=20, image=img_exit, 106 | relief=tk.FLAT, command=self.parent.on_exit) 107 | infoButton = tk.Button(toolbar, width=20, image=img_info, 108 | relief=tk.FLAT, command=self.on_about) 109 | 110 | exitButton.image = img_exit 111 | infoButton.image = img_info 112 | 113 | exitButton.pack(side=tk.LEFT, padx=2, pady=2) 114 | infoButton.pack(side=tk.LEFT, padx=2, pady=2) 115 | 116 | toolbar.config(bg=self.nametowidget(".").engine.get_rgb(240, 240, 237)) 117 | toolbar.pack(side=tk.TOP, fill=tk.X) 118 | 119 | def init_status_bar(self): 120 | 121 | self.status = ttk.Label(self, 122 | textvariable=self.status_bar_text, 123 | style='StatusBar.TLabel', 124 | anchor=tk.W) 125 | self.status.pack(side=tk.BOTTOM, fill=tk.X) 126 | 127 | def init_ui(self): 128 | 129 | """create widgets""" 130 | frm_main = ttk.Frame(self, style="App.TFrame") 131 | frm_left = ttk.Frame(frm_main, style="App.TFrame", padding=8) 132 | #products 133 | #----------------------------------------------------------------------- 134 | cols = (["#0", "id", "w", False, 0, 0], 135 | ["#1", "Product", "w", True, 100, 100], 136 | ["#2", "Description", "w", True, 100, 100], 137 | ["#3", "Stock", "center", True, 20, 20], 138 | ["#4", "Price", "center", True, 20, 20],) 139 | 140 | self.lblProdutcs = ttk.LabelFrame(frm_left, style="App.TLabelframe", text="Products",) 141 | self.lstProducts = self.nametowidget(".").engine.get_tree(self.lblProdutcs, cols,) 142 | self.lstProducts.tag_configure("is_enable", background="light gray") 143 | self.lstProducts.tag_configure("is_zero", background=self.nametowidget(".").engine.get_rgb(255, 160, 122)) 144 | self.lstProducts.bind("<>", self.on_prduct_selected) 145 | self.lstProducts.bind("", self.on_prduct_activated) 146 | self.lblProdutcs.pack(fill=tk.BOTH, expand=1) 147 | 148 | #categories 149 | #----------------------------------------------------------------------- 150 | self.lblCombo = ttk.LabelFrame(frm_left, style="App.TLabelframe", padding=2) 151 | self.cbCombo = ttk.Combobox(self.lblCombo, style="App.TCombobox") 152 | self.cbCombo.bind("<>", self.get_selected_combo_item) 153 | self.cbCombo.pack(side=tk.TOP, anchor=tk.W, fill=tk.X, expand=1) 154 | self.lblCombo.pack(side=tk.TOP, anchor=tk.W, fill=tk.X, pady=5, expand=0) 155 | 156 | #buttons and radio 157 | #----------------------------------------------------------------------- 158 | frm_right = ttk.Frame(frm_main, style="App.TFrame", padding=4) 159 | 160 | bts = (("Reset", 0, self.on_reset, ""), 161 | ("New", 0, self.on_add, ""), 162 | ("Edit", 0, self.on_prduct_activated, ""), 163 | ("Close", 0, self.parent.on_exit, "")) 164 | 165 | for btn in bts: 166 | ttk.Button(frm_right, 167 | style="App.TButton", 168 | text=btn[0], 169 | underline=btn[1], 170 | command=btn[2],).pack(fill=tk.X, padx=5, pady=5) 171 | self.parent.bind(btn[3], btn[2]) 172 | 173 | w = ttk.LabelFrame(frm_right, style="App.TLabelframe", text="Combo data") 174 | voices = ("Categories", "Suppliers") 175 | for index, text in enumerate(voices): 176 | ttk.Radiobutton(w, 177 | style="App.TRadiobutton", 178 | text=text, 179 | variable=self.option_id, 180 | command=self.set_combo_values, 181 | value=index,).pack(anchor=tk.W) 182 | 183 | w.pack() 184 | 185 | frm_right.pack(side=tk.RIGHT, fill=tk.Y, expand=0) 186 | frm_left.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) 187 | frm_main.pack(fill=tk.BOTH, expand=1) 188 | 189 | def center_ui(self): 190 | 191 | ws = self.nametowidget(".").winfo_screenwidth() 192 | hs = self.nametowidget(".").winfo_screenheight() 193 | # calculate position x, y 194 | d = self.nametowidget(".").engine.get_dimensions() 195 | w = int(d["w"]) 196 | h = int(d["h"]) 197 | x = (ws/2) - (w/2) 198 | y = (hs/2) - (h/2) 199 | self.nametowidget(".").geometry("%dx%d+%d+%d" % (w, h, x, y)) 200 | 201 | def on_open(self, evt=None): 202 | 203 | self.on_reset() 204 | #Update clock 205 | self.periodic_call() 206 | 207 | def on_reset(self, evt=None): 208 | 209 | self.selected_item = None 210 | sql = "SELECT * FROM {0} ORDER BY product ASC;".format(self.table) 211 | self.set_tree_values(sql, ()) 212 | self.set_combo_values() 213 | 214 | def on_add(self, evt=None): 215 | frames.product.UI(self).on_open() 216 | 217 | def on_categories(self): 218 | frames.categories.UI(self).on_open() 219 | 220 | def on_suppliers(self): 221 | frames.suppliers.UI(self).on_open() 222 | 223 | def on_prduct_selected(self, evt): 224 | 225 | if self.lstProducts.focus(): 226 | item_iid = self.lstProducts.selection() 227 | pk = int(item_iid[0]) 228 | self.selected_item = self.nametowidget(".").engine.get_selected(self.table, self.primary_key, pk) 229 | 230 | def on_prduct_activated(self, evt=None): 231 | 232 | if self.lstProducts.focus(): 233 | 234 | item_iid = self.lstProducts.selection() 235 | 236 | frames.product.UI(self, item_iid).on_open() 237 | 238 | else: 239 | messagebox.showwarning(self.nametowidget(".").title(), 240 | self.nametowidget(".").engine.no_selected, 241 | parent=self) 242 | 243 | 244 | def get_selected_combo_item(self, evt=None): 245 | 246 | if self.cbCombo.current() != -1: 247 | 248 | index = self.cbCombo.current() 249 | selected_id = self.dict_combo_values[index] 250 | 251 | if self.option_id.get() != 1: 252 | field = "category_id" 253 | else: 254 | field = "supplier_id" 255 | 256 | sql = "SELECT * FROM products WHERE {0}=? ORDER BY product;".format(field) 257 | args = (selected_id,) 258 | self.set_tree_values(sql, args) 259 | else: 260 | self.on_open() 261 | 262 | def set_tree_values(self, sql, args): 263 | 264 | for i in self.lstProducts.get_children(): 265 | self.lstProducts.delete(i) 266 | 267 | rs = self.nametowidget(".").engine.read(True, sql, args) 268 | 269 | if rs: 270 | 271 | for i in rs: 272 | 273 | if i[7] == 0: 274 | tag_config = ("is_enable") 275 | elif i[6] < 1: 276 | tag_config = ("is_zero") 277 | else: 278 | tag_config = ("") 279 | 280 | self.lstProducts.insert("", tk.END, iid=i[0], text=i[0], 281 | values=(i[1], i[4], i[6], i[5]), 282 | tags=tag_config) 283 | 284 | s = "{0} {1}".format("Products", len(self.lstProducts.get_children())) 285 | 286 | self.lblProdutcs["text"] = s 287 | 288 | def set_combo_values(self): 289 | 290 | self.cbCombo.set("") 291 | 292 | index = 0 293 | values = [] 294 | 295 | if self.option_id.get() != 1: 296 | self.lblCombo["text"] = "Categories" 297 | sql = "SELECT category_id, category\ 298 | FROM categories\ 299 | WHERE enable =1\ 300 | ORDER BY category;" 301 | else: 302 | self.lblCombo["text"] = "Suppliers" 303 | sql = "SELECT supplier_id, company\ 304 | FROM suppliers\ 305 | WHERE enable =1\ 306 | ORDER BY company;" 307 | 308 | rs = self.nametowidget(".").engine.read(True, sql, ()) 309 | 310 | for i in rs: 311 | self.dict_combo_values[index] = i[0] 312 | index += 1 313 | values.append(i[1]) 314 | 315 | self.cbCombo.set("") 316 | self.cbCombo["values"] = values 317 | 318 | def on_license(self): 319 | frames.license.UI(self).on_open() 320 | 321 | def on_python_version(self): 322 | s = self.nametowidget(".").engine.get_python_version() 323 | messagebox.showinfo(self.nametowidget(".").title(), s, parent=self) 324 | 325 | def on_tkinter_version(self): 326 | s = "Tkinter patchlevel\n{0}".format(self.nametowidget(".").tk.call("info", "patchlevel")) 327 | messagebox.showinfo(self.nametowidget(".").title(), s, parent=self) 328 | 329 | def on_about(self,): 330 | messagebox.showinfo(self.nametowidget(".").title(), 331 | self.nametowidget(".").info, 332 | parent=self) 333 | 334 | def on_dump(self): 335 | self.nametowidget(".").engine.busy(self) 336 | self.nametowidget(".").engine.dump() 337 | self.nametowidget(".").engine.not_busy(self) 338 | messagebox.showinfo(self.nametowidget(".").title(), "Dump executed.", parent=self) 339 | 340 | def on_vacuum(self): 341 | sql = "VACUUM;" 342 | self.nametowidget(".").engine.busy(self) 343 | self.nametowidget(".").engine.write(sql) 344 | self.nametowidget(".").engine.not_busy(self) 345 | messagebox.showinfo(self.nametowidget(".").title(), "Vacuum executed.", parent=self) 346 | 347 | def on_log(self,): 348 | self.nametowidget(".").engine.get_log_file() 349 | 350 | def periodic_call(self): 351 | 352 | self.parent.clock.check_queue(self.status_bar_text) 353 | 354 | if self.parent.clock.is_alive(): 355 | self.after(1, self.periodic_call) 356 | 357 | 358 | class App(tk.Tk): 359 | """Application start here""" 360 | def __init__(self, *args, **kwargs): 361 | super().__init__() 362 | 363 | self.engine = Engine() 364 | 365 | self.protocol("WM_DELETE_WINDOW", self.on_exit) 366 | self.set_title(kwargs["title"]) 367 | self.engine.set_style(kwargs["theme"]) 368 | self.set_icon() 369 | self.set_info() 370 | # set clock and start it. 371 | self.set_clock() 372 | 373 | w = Main(self) 374 | w.on_open() 375 | w.pack(fill=tk.BOTH, expand=1) 376 | 377 | def set_clock(self,): 378 | self.clock = self.engine.get_clock() 379 | self.clock.start() 380 | 381 | def set_title(self, title): 382 | s = "{0}".format(title) 383 | self.title(s) 384 | 385 | def set_icon(self): 386 | icon = tk.PhotoImage(data=self.engine.get_icon("app")) 387 | self.call("wm", "iconphoto", self._w, "-default", icon) 388 | 389 | def set_info(self,): 390 | msg = "{0}\nauthor: {1}\ncopyright: {2}\ncredits: {3}\nlicense: {4}\nversion: {5}\ 391 | \nmaintainer: {6}\nemail: {7}\ndate: {8}\nstatus: {9}" 392 | info = msg.format(self.title(), __author__, __copyright__, __credits__, __license__, __version__, __maintainer__, __email__, __date__, __status__) 393 | self.info = info 394 | 395 | def on_exit(self, evt=None): 396 | if messagebox.askokcancel(self.title(), "Do you want to quit?", parent=self): 397 | self.engine.con.close() 398 | if self.clock is not None: 399 | self.clock.stop() 400 | self.destroy() 401 | 402 | def main(): 403 | #if you want pass a number of arbitrary args or kwargs... 404 | args = [] 405 | 406 | for i in sys.argv: 407 | args.append(i) 408 | 409 | foo = Engine() 410 | 411 | theme = foo.get_theme() 412 | 413 | kwargs = {"title":"Tkinterlite", "theme":theme} 414 | 415 | app = App(*args, **kwargs) 416 | 417 | app.mainloop() 418 | 419 | 420 | if __name__ == "__main__": 421 | main() 422 | -------------------------------------------------------------------------------- /frames/product.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # ----------------------------------------------------------------------------- 3 | # project: tkinterlite 4 | # authors: 1966bc 5 | # mailto: [giuseppecostanzi@gmail.com] 6 | # modify: hiems MMXXI 7 | # ----------------------------------------------------------------------------- 8 | import tkinter as tk 9 | from tkinter import ttk 10 | from tkinter import messagebox 11 | 12 | 13 | class UI(tk.Toplevel): 14 | def __init__(self, parent, index=None): 15 | super().__init__(name="product") 16 | 17 | self.parent = parent 18 | self.index = index 19 | self.resizable(0, 0) 20 | self.transient(parent) 21 | self.columnconfigure(0, weight=1) 22 | self.columnconfigure(1, weight=2) 23 | self.columnconfigure(2, weight=1) 24 | 25 | self.product = tk.StringVar() 26 | self.stock = tk.IntVar() 27 | self.package = tk.StringVar() 28 | self.price = tk.DoubleVar() 29 | self.enable = tk.BooleanVar() 30 | 31 | self.val_int = self.nametowidget(".").engine.get_validate_integer(self) 32 | self.val_float = self.nametowidget(".").engine.get_validate_float(self) 33 | self.nametowidget(".").engine.center_me(self) 34 | self.init_ui() 35 | 36 | def init_ui(self): 37 | 38 | paddings = {"padx": 5, "pady": 5} 39 | 40 | self.frm_main = ttk.Frame(self, style="App.TFrame") 41 | self.frm_main.grid(row=0, column=0) 42 | 43 | frm_left = ttk.Frame(self.frm_main, style="App.TFrame") 44 | frm_left.grid(row=0, column=0, sticky=tk.NS, **paddings) 45 | 46 | r = 0 47 | c = 1 48 | ttk.Label(frm_left, style="App.TLabel", text="Product:",).grid(row=r, sticky=tk.W) 49 | self.txtProduct = ttk.Entry(frm_left, 50 | style="Product.TEntry", 51 | textvariable=self.product) 52 | self.txtProduct.grid(row=r, column=c, sticky=tk.EW, **paddings) 53 | 54 | r += 1 55 | ttk.Label(frm_left, style="App.TLabel", text="Suppliers:",).grid(row=r, sticky=tk.W) 56 | self.cbSuppliers = ttk.Combobox(frm_left,) 57 | self.cbSuppliers.grid(row=r, column=c, sticky=tk.EW, **paddings) 58 | 59 | r += 1 60 | ttk.Label(frm_left, style="App.TLabel", text="Categories:",).grid(row=r, sticky=tk.W) 61 | self.cbCategories = ttk.Combobox(frm_left,) 62 | self.cbCategories.grid(row=r, column=c, sticky=tk.EW, **paddings) 63 | 64 | r += 1 65 | ttk.Label(frm_left, style="App.TLabel", text="Package:").grid(row=r, sticky=tk.W) 66 | ent_package = ttk.Entry(frm_left, style="Package.TEntry", textvariable=self.package) 67 | ent_package.grid(row=r, column=c, sticky=tk.EW, **paddings) 68 | 69 | r += 1 70 | ttk.Label(frm_left, style="App.TLabel", text="Price:").grid(row=r, sticky=tk.W) 71 | ent_price = ttk.Entry(frm_left, justify=tk.CENTER, width=8, validate="key", 72 | validatecommand=self.val_float, textvariable=self.price) 73 | ent_price.grid(row=r, column=c, sticky=tk.W, **paddings) 74 | 75 | r += 1 76 | ttk.Label(frm_left, style="App.TLabel", text="Stock:").grid(row=r, sticky=tk.W) 77 | ent_stock = ttk.Entry(frm_left, justify=tk.CENTER, width=8, validate="key", 78 | validatecommand=self.val_int, textvariable=self.stock) 79 | ent_stock.grid(row=r, column=c, sticky=tk.W, **paddings) 80 | 81 | r += 1 82 | ttk.Label(frm_left, style="App.TLabel", text="Enable:").grid(row=r, sticky=tk.W) 83 | chk_enable = ttk.Checkbutton(frm_left, onvalue=1, offvalue=0, variable=self.enable,) 84 | chk_enable.grid(row=r, column=c, sticky=tk.EW, **paddings) 85 | 86 | frm_right = ttk.Frame(self.frm_main, style="App.TFrame") 87 | frm_right.grid(row=0, column=1, sticky=tk.NS, **paddings) 88 | 89 | r = 0 90 | c = 0 91 | btn_save = ttk.Button(frm_right, style="App.TButton", text="Save", underline=0, command=self.on_save,) 92 | self.bind("", self.on_save) 93 | btn_save.grid(row=r, column=c, sticky=tk.EW, **paddings) 94 | 95 | if self.index is not None: 96 | r += 1 97 | btn = ttk.Button(frm_right, style="App.TButton", text="Delete", underline=0, command=self.on_delete,) 98 | self.bind("", self.on_delete) 99 | btn.grid(row=r, column=c, sticky=tk.EW, **paddings) 100 | 101 | r += 1 102 | btn_cancel = ttk.Button(frm_right, style="App.TButton", text="Cancel", underline=0, command=self.on_cancel) 103 | self.bind("", self.on_cancel) 104 | btn_cancel.grid(row=r, column=c, sticky=tk.EW, **paddings) 105 | 106 | def on_open(self): 107 | 108 | self.set_categories() 109 | self.set_suppliers() 110 | 111 | if self.index is not None: 112 | msg = "Update {0}".format(self.winfo_name().capitalize()) 113 | self.set_values() 114 | else: 115 | msg = "Insert {0}".format(self.winfo_name().capitalize()) 116 | self.enable.set(1) 117 | 118 | self.title(msg) 119 | self.txtProduct.focus() 120 | 121 | def set_values(self,): 122 | 123 | self.product.set(self.parent.selected_item[1]) 124 | #set value on cbSuppliers 125 | key = next(key 126 | for key, value 127 | in self.dict_suppliers.items() 128 | if value == self.parent.selected_item[2]) 129 | self.cbSuppliers.current(key) 130 | #set value on cbCategories 131 | key = next(key 132 | for key, value 133 | in self.dict_categories.items() 134 | if value == self.parent.selected_item[3]) 135 | self.cbCategories.current(key) 136 | 137 | self.package.set(self.parent.selected_item[4]) 138 | self.price.set(self.parent.selected_item[5]) 139 | self.stock.set(self.parent.selected_item[6]) 140 | self.enable.set(self.parent.selected_item[7]) 141 | 142 | def get_values(self,): 143 | 144 | return [self.product.get(), 145 | self.dict_suppliers[self.cbSuppliers.current()], 146 | self.dict_categories[self.cbCategories.current()], 147 | self.package.get(), 148 | self.price.get(), 149 | self.stock.get(), 150 | self.enable.get()] 151 | 152 | def on_save(self, evt=None): 153 | 154 | if self.nametowidget(".").engine.on_fields_control(self.frm_main, 155 | self.nametowidget(".").title()) == False: return 156 | 157 | if messagebox.askyesno(self.nametowidget(".").title(), 158 | self.nametowidget(".").engine.ask_to_save, 159 | parent=self) == True: 160 | 161 | args = self.get_values() 162 | 163 | if self.index is not None: 164 | 165 | sql = self.nametowidget(".").engine.get_update_sql(self.parent.table, self.parent.primary_key) 166 | 167 | args.append(self.parent.selected_item[0]) 168 | 169 | else: 170 | 171 | sql = self.nametowidget(".").engine.get_insert_sql(self.parent.table, len(args)) 172 | 173 | product_id = self.nametowidget(".").engine.write(sql, args) 174 | self.parent.on_reset() 175 | 176 | if self.index is not None: 177 | self.parent.lstProducts.selection_set(self.index) 178 | self.parent.lstProducts.see(self.index) 179 | else: 180 | self.parent.lstProducts.selection_set(product_id) 181 | self.parent.lstProducts.see(product_id) 182 | 183 | self.on_cancel() 184 | 185 | def on_delete(self, evt=None): 186 | 187 | sql = "DELETE FROM products WHERE product_id=?;" 188 | 189 | if messagebox.askyesno(self.nametowidget(".").title(), 190 | self.nametowidget(".").engine.ask_to_delete, 191 | parent=self) == True: 192 | 193 | args = (self.parent.selected_item[0],) 194 | self.nametowidget(".").engine.write(sql, args) 195 | self.parent.get_selected_combo_item() 196 | self.on_cancel() 197 | else: 198 | messagebox.showinfo(self.nametowidget(".").title(), 199 | self.nametowidget(".").engine.abort, 200 | parent=self) 201 | 202 | def set_categories(self): 203 | 204 | sql = "SELECT category_id, category FROM categories ORDER BY category ASC;" 205 | index = 0 206 | self.dict_categories = {} 207 | values = [] 208 | rs = self.nametowidget(".").engine.read(True, sql, ()) 209 | 210 | for i in rs: 211 | self.dict_categories[index] = i[0] 212 | index += 1 213 | values.append(i[1]) 214 | 215 | self.cbCategories["values"] = values 216 | 217 | def set_suppliers(self,): 218 | 219 | sql = "SELECT supplier_id, company FROM suppliers ORDER BY company ASC;" 220 | index = 0 221 | self.dict_suppliers = {} 222 | values = [] 223 | 224 | rs = self.nametowidget(".").engine.read(True, sql, ()) 225 | 226 | for i in rs: 227 | self.dict_suppliers[index] = i[0] 228 | index += 1 229 | values.append(i[1]) 230 | 231 | self.cbSuppliers["values"] = values 232 | 233 | def on_cancel(self, evt=None): 234 | self.destroy() 235 | -------------------------------------------------------------------------------- /frames/supplier.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # ----------------------------------------------------------------------------- 3 | # project: tkinterlite 4 | # authors: 1966bc 5 | # mailto: [giuseppecostanzi@gmail.com] 6 | # modify: hiems MMXXI 7 | # ------------------------------------------------------------------------------- 8 | import tkinter as tk 9 | from tkinter import ttk 10 | from tkinter import messagebox 11 | 12 | class UI(tk.Toplevel): 13 | def __init__(self, parent, index=None): 14 | super().__init__(name="supplier") 15 | 16 | self.parent = parent 17 | self.index = index 18 | self.transient(parent) 19 | self.resizable(0, 0) 20 | self.columnconfigure(0, weight=1) 21 | self.columnconfigure(1, weight=2) 22 | self.columnconfigure(2, weight=1) 23 | 24 | self.company = tk.StringVar() 25 | self.enable = tk.BooleanVar() 26 | self.init_ui() 27 | self.nametowidget(".").engine.center_me(self) 28 | 29 | def init_ui(self): 30 | 31 | paddings = {"padx": 5, "pady": 5} 32 | 33 | self.frm_main = ttk.Frame(self, style="App.TFrame") 34 | self.frm_main.grid(row=0, column=0) 35 | 36 | frm_left = ttk.Frame(self.frm_main, style="App.TFrame") 37 | frm_left.grid(row=0, column=0, sticky=tk.NS, **paddings) 38 | 39 | r = 0 40 | c = 1 41 | ttk.Label(frm_left, style="App.TLabel", text="Company:",).grid(row=r, sticky=tk.W) 42 | self.txtCompany = ttk.Entry(frm_left, textvariable=self.company) 43 | self.txtCompany.grid(row=r, column=c, sticky=tk.EW, **paddings) 44 | 45 | r += 1 46 | ttk.Label(frm_left, style="App.TLabel", text="Enable:").grid(row=r, sticky=tk.W) 47 | chk_enable = ttk.Checkbutton(frm_left, onvalue=1, offvalue=0, variable=self.enable,) 48 | chk_enable.grid(row=r, column=c, sticky=tk.W) 49 | 50 | frm_right = ttk.Frame(self.frm_main, style="App.TFrame") 51 | frm_right.grid(row=0, column=1, sticky=tk.NS, **paddings) 52 | 53 | r = 0 54 | c = 0 55 | btn_save = ttk.Button(frm_right, style="App.TButton", text="Save", underline=0, command=self.on_save,) 56 | self.bind("", self.on_save) 57 | btn_save.grid(row=r, column=c, sticky=tk.EW, **paddings) 58 | 59 | r += 1 60 | btn_cancel = ttk.Button(frm_right, style="App.TButton", text="Cancel", underline=0, command=self.on_cancel) 61 | self.bind("", self.on_cancel) 62 | btn_cancel.grid(row=r, column=c, sticky=tk.EW, **paddings) 63 | 64 | 65 | def on_open(self): 66 | 67 | if self.index is not None: 68 | msg = "Edit {0}".format(self.winfo_name().title()) 69 | self.set_values() 70 | else: 71 | msg = "Add {0}".format(self.winfo_name().title()) 72 | self.enable.set(1) 73 | 74 | self.title(msg) 75 | self.txtCompany.focus() 76 | 77 | def set_values(self,): 78 | 79 | self.company.set(self.parent.selected_item[1]) 80 | self.enable.set(self.parent.selected_item[2]) 81 | 82 | def get_values(self,): 83 | 84 | return [self.company.get(), 85 | self.enable.get()] 86 | 87 | def on_save(self, evt=None): 88 | 89 | if self.nametowidget(".").engine.on_fields_control(self.frm_main, self.nametowidget(".").title()) == False: return 90 | 91 | if messagebox.askyesno(self.nametowidget(".").title(), 92 | self.nametowidget(".").engine.ask_to_save, 93 | parent=self) == True: 94 | 95 | args = self.get_values() 96 | 97 | if self.index is not None: 98 | 99 | sql = self.nametowidget(".").engine.get_update_sql(self.parent.table, self.parent.primary_key) 100 | 101 | args.append(self.parent.selected_item[0]) 102 | 103 | else: 104 | 105 | sql = self.nametowidget(".").engine.get_insert_sql(self.parent.table, len(args)) 106 | 107 | last_id = self.nametowidget(".").engine.write(sql, args) 108 | self.parent.on_open() 109 | 110 | if self.index is not None: 111 | self.parent.lstItems.see(self.index) 112 | self.parent.lstItems.selection_set(self.index) 113 | else: 114 | #force focus on listbox 115 | idx = list(self.parent.dict_items.keys())[list(self.parent.dict_items.values()).index(last_id)] 116 | self.parent.lstItems.selection_set(idx) 117 | self.parent.lstItems.see(idx) 118 | 119 | self.on_cancel() 120 | 121 | else: 122 | messagebox.showinfo(self.nametowidget(".").title(), 123 | self.nametowidget(".").engine.abort, 124 | parent=self) 125 | 126 | def on_cancel(self, evt=None): 127 | self.destroy() 128 | -------------------------------------------------------------------------------- /frames/suppliers.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # ----------------------------------------------------------------------------- 3 | # project: tkinterlite 4 | # authors: 1966bc 5 | # mailto: [giuseppecostanzi@gmail.com] 6 | # modify: hiems MMXXI 7 | # ----------------------------------------------------------------------------- 8 | import tkinter as tk 9 | from tkinter import ttk 10 | from tkinter import messagebox 11 | import frames.supplier as ui 12 | 13 | SQL = "SELECT * FROM suppliers ORDER BY company ASC;" 14 | 15 | 16 | class UI(tk.Toplevel): 17 | def __init__(self, parent,): 18 | super().__init__(name="suppliers") 19 | 20 | self.parent = parent 21 | self.attributes("-topmost", True) 22 | self.protocol("WM_DELETE_WINDOW", self.on_cancel) 23 | self.table = "suppliers" 24 | self.primary_key = "supplier_id" 25 | self.items = tk.IntVar() 26 | self.obj = None 27 | self.init_ui() 28 | self.nametowidget(".").engine.center_me(self) 29 | 30 | def init_ui(self): 31 | 32 | frm_main = ttk.Frame(self, style="App.TFrame") 33 | 34 | frm_left = ttk.Frame(frm_main, style="App.TFrame", padding=8) 35 | 36 | ttk.Label(frm_left, style="App.TLabel", textvariable=self.items,).pack(fill=tk.X, expand=0) 37 | 38 | sb = ttk.Scrollbar(frm_left, orient=tk.VERTICAL) 39 | self.lstItems = tk.Listbox(frm_left, yscrollcommand=sb.set,) 40 | self.lstItems.bind("<>", self.on_item_selected) 41 | self.lstItems.bind("", self.on_item_activated) 42 | sb.config(command=self.lstItems.yview) 43 | self.lstItems.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) 44 | sb.pack(fill=tk.Y, expand=1) 45 | 46 | frm_right = ttk.Frame(frm_main, style="App.TFrame", padding=4) 47 | 48 | bts = (("Add", 0, self.on_add, ""), 49 | ("Edit", 0, self.on_item_activated, ""), 50 | ("Close", 0, self.on_cancel, "")) 51 | 52 | for btn in bts: 53 | ttk.Button(frm_right, 54 | style="App.TButton", 55 | text=btn[0], 56 | underline=btn[1], 57 | command=btn[2],).pack(fill=tk.X, padx=5, pady=5) 58 | self.bind(btn[3], btn[2]) 59 | 60 | frm_main.pack(fill=tk.BOTH, expand=1) 61 | frm_left.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) 62 | frm_right.pack(side=tk.RIGHT, fill=tk.Y, expand=0) 63 | 64 | def on_open(self,): 65 | 66 | msg = "{0}".format(self.winfo_name().title()) 67 | self.title(msg) 68 | self.set_values() 69 | 70 | def set_values(self): 71 | 72 | self.lstItems.delete(0, tk.END) 73 | index = 0 74 | self.dict_items = {} 75 | 76 | rs = self.nametowidget(".").engine.read(True, SQL, ()) 77 | 78 | if rs: 79 | for i in rs: 80 | s = "{:}".format(i[1]) 81 | self.lstItems.insert(tk.END, s) 82 | if i[2] != 1: 83 | self.lstItems.itemconfig(index, {"bg": "light gray"}) 84 | self.dict_items[index] = i[0] 85 | index += 1 86 | 87 | msg = ("Items: {0}".format(self.lstItems.size())) 88 | self.items.set(msg) 89 | 90 | def on_add(self, evt=None): 91 | 92 | self.obj = ui.UI(self) 93 | self.obj.on_open() 94 | 95 | def on_item_selected(self, evt=None): 96 | 97 | if self.lstItems.curselection(): 98 | index = self.lstItems.curselection()[0] 99 | pk = self.dict_items.get(index) 100 | self.selected_item = self.nametowidget(".").engine.get_selected(self.table, 101 | self.primary_key, 102 | pk) 103 | def on_item_activated(self, evt=None): 104 | 105 | if self.lstItems.curselection(): 106 | index = self.lstItems.curselection()[0] 107 | self.obj = ui.UI(self, index) 108 | self.obj.on_open() 109 | 110 | else: 111 | messagebox.showwarning(self.nametowidget(".").title(), 112 | self.nametowidget(".").engine.no_selected, 113 | parent=self) 114 | 115 | def on_cancel(self, evt=None): 116 | if self.obj is not None: 117 | self.obj.destroy() 118 | self.destroy() 119 | -------------------------------------------------------------------------------- /info: -------------------------------------------------------------------------------- 1 | iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAABWNJREFUSMellktsHWcVx3/fY+bOvX7Gjq9Tkzo0D+zEaVOa0KhCSDwlICAWLAEpBbEqQkVICKlixaIsUEGggCooINEFCxaggBJRQaJSFBNAStKkdu0SNSauE7/va2buN9+Dxb1NnOAiJI50NPpmzpz/Of85jxFsIyGErUcJREACxN17BsiBAvBvGwoh/sOX+C+OVWZs38W55X3LtexICExoLUcEYH1YlYLXRwfKl4/tr76RxKoBuO2AxDs4L73wh2sP31xrfaG/J/n4YE95TymKSlpJBGCdJzNFu5bmN1pZ++zu4cqLJz966ArQvh9E3O/81evLlR+evvzZSjn55vjo0KEkKmFsoHAe7zt2Ugq0EsRaYqzh5vLGTJrn33nqxMO/PvxQNd0KIu8cJp/m7PRs/LXnz510qO/vGh46lLYFy7WczVabZl6QGUtmLM28oNYyrNRyWjmMDg0e9Kjvff0nL3/xpYvzsdj55bs8A/ix9/Py9E1eWVj99Fh1+Ln3jI8NZ22PKRzWdaLvSzQfemSUfbt6eWstpZEXOBcw1pEXgYGeSnm93nr8Z2cvvb4xvTxbeijhj7/5ZQfgQrYfr92Do9XhHx2d3LvfeUFhPdYFrOsAfWBqhA8/sovxkQqN1PDav2p4H+7aWM9Ab7mycHv9wEq5ffbPs7dq7vo5JI89zd73HUOXS5/fM1Y96oUiNZas6GhedGipt/I7addbOZnpPutqaiyFk+zbXX2sVEk+d+zECXj0Kwie+AbUWyMPTO4788Hj7z0aRxHhvlp2LpBE8MTECADTc6u0LWxT9hAc5/966R8LV+c+wUDvikZJKMdTA329Ez5IMmO39AXEWnJgrI9YSZY2MgCSSFFL29sCKCkYHuybWKiUptD6vBaxJthiMo7j3qxwhODvAegplfjSxw6wa0cFITol+uKf3uBXryyglOgYbclZSkk5SXplpA+KJDovo94+hKAakOSmIDe2q47cBpYbBd/97QznXl1CSdFptACZg9xCZgN54ckLR2E9xjoKFxAiVJOBAXQQkhCCNIUjN67TdEKAVCAluRVc+Gedgw8O3InSejBBEoREIgg+YExBI81ZqWWsr63inBetdoEuGpvgw+qtzSaZSIi1QpdKKC1QUUBpgQuKwgUInhACmXGsZBCCpZW1abYysjSlyHPwHgoLwa/R3EST5+DdfK2RpjXbrKA0MrYIbRFRCRnFuCBY2sxoNhsQYGkzZW7F0B1MYAE0qAiEBRNSnJsjb6MxFgpzFZtfR8rDSI0XGqQGobuTWuBChwqAICToBGTYOi7Bu861yK5jzTWEQNLM4PJf3iJvnsYZ0BEoDTLqRCQVKIlUYkulCFDd76Tirr0GHYNrQ14/zaWLizRzFKtD8PhxMPkiSn2E3pERdNwFitnZo3juM1U+OTXEjh6NELB7MObIAxHTN1JSKyH4bgYWNhZmaG08w/jeFS6/iYSXoJXC86dmaa49S32xhlQdeoQCpREqYn7dcma2xZnZFvPrDvF21EKCUp1saos1mmvPcuHUDK0M+P2WjXbkKcizmMEdX2X43d9idKKfpB+URkcRIioRdAkECGsIJsdaC85CXofbs3VW3/w2m+s/oFQxXDl1d1wDcPtv8K7jjrT1d2y6iGlOoaJhkn58VMarEl5FeBQ+CHwAbBs2b8LStXnWFp6hXvsppZLhyo+338kATJ6EtCkYrh6m0vckfaOfon90Dz1DMVGl84bJoLVuaNy6Ieq3f0fa+HlYW75KT29g5hfvvPTv+ZU49CSiKHTo7RkPUfIoUXIwKL0TQDi7SpHPiKJ9STTThRBF1r/2Av+3qHs4/d/k30J8x2DqEInCAAAAAElFTkSuQmCC 2 | -------------------------------------------------------------------------------- /log.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1966bc/Tkinterlite/57e56474f54f177b9ab1e9e570223bc7caf42e66/log.txt -------------------------------------------------------------------------------- /northwind.sl3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1966bc/Tkinterlite/57e56474f54f177b9ab1e9e570223bc7caf42e66/northwind.sl3 -------------------------------------------------------------------------------- /theme: -------------------------------------------------------------------------------- 1 | default -------------------------------------------------------------------------------- /tkinterlite.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | #----------------------------------------------------------------------------- 4 | # project: tkinterlite 5 | # authors: 1966bc 6 | # mailto: [giuseppecostanzi@gmail.com] 7 | # modify: hiems MMXX 8 | #----------------------------------------------------------------------------- 9 | import sys 10 | import profile 11 | import pstats 12 | import frames.main as main 13 | 14 | if len(sys.argv) > 1: 15 | profile.run('main.main()', 'profile_results') 16 | p = pstats.Stats('profile_results') 17 | p.sort_stats('cumulative').print_stats(10) 18 | else: 19 | main.main() 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /tkinterlite.sql: -------------------------------------------------------------------------------- 1 | BEGIN TRANSACTION; 2 | CREATE TABLE "products" ( 3 | 'product_id' INTEGER PRIMARY KEY, 4 | 'product' TEXT, 5 | 'supplier_id' INTEGER, 6 | 'category_id' INTEGER, 7 | 'package' TEXT, 8 | 'price' REAL, 9 | 'stock' INTEGER, 10 | 'enable' BOOLEAN DEFAULT '1' 11 | ); 12 | INSERT INTO "products" VALUES(1, 'Chai', 1, 1, '10 boxes x 20 bags', 18.0, 18, 1); 13 | INSERT INTO "products" VALUES(2, 'Chang', 1, 1, '24 - 12 oz bottles', 19.0, 19, 0); 14 | INSERT INTO "products" VALUES(3, 'Aniseed Syrup', 2, 1, '12 - 550 ml bottles', 10.0, 10, 1); 15 | INSERT INTO "products" VALUES(4, 'Chef Anton''s Cajun Seasoning', 2, 2, '48 - 6 oz jars', 22.0, 22, 0); 16 | INSERT INTO "products" VALUES(5, 'Chef Anton''s Gumbo Mix', 2, 2, '36 boxes', 21.35, 0, 1); 17 | INSERT INTO "products" VALUES(6, 'Grandma''s Boysenberry Spread', 3, 2, '12 - 8 oz jars', 25.0, 120, 0); 18 | INSERT INTO "products" VALUES(7, 'Uncle Bob''s Organic Dried Pears', 3, 7, '12 - 1 lb pkgs.', 30.0, 15, 0); 19 | INSERT INTO "products" VALUES(8, 'Northwoods Cranberry Sauce', 3, 2, '12 - 12 oz jars', 40.0, 6, 0); 20 | INSERT INTO "products" VALUES(9, 'Mishi Kobe Niku', 4, 6, '18 - 500 g pkgs.', 97.0, 29, 1); 21 | INSERT INTO "products" VALUES(10, 'Ikura', 4, 8, '12 - 200 ml jars', 31.0, 31, 0); 22 | INSERT INTO "products" VALUES(11, 'Queso Cabrales', 5, 4, '1 kg pkg.', 21.0, 22, 0); 23 | INSERT INTO "products" VALUES(12, 'Queso Manchego La Pastora', 5, 4, '10 - 500 g pkgs.', 38.0, 86, 0); 24 | INSERT INTO "products" VALUES(13, 'Konbu', 6, 8, '2 kg box', 6.0, 24, 0); 25 | INSERT INTO "products" VALUES(14, 'Tofu', 6, 7, '40 - 100 g pkgs.', 23.25, 35, 0); 26 | INSERT INTO "products" VALUES(15, 'Genen Shouyu', 6, 2, '24 - 250 ml bottles', 15.5, 39, 0); 27 | INSERT INTO "products" VALUES(16, 'Pavlova', 7, 3, '32 - 500 g boxes', 17.45, 29, 0); 28 | INSERT INTO "products" VALUES(17, 'Alice Mutton', 6, 7, '20 - 1 kg tins', 39.0, 39, 1); 29 | INSERT INTO "products" VALUES(18, 'Carnarvon Tigers', 8, 7, '16 kg pkg.', 62.5, 62.5, 0); 30 | INSERT INTO "products" VALUES(19, 'Teatime Chocolate Biscuits', 8, 3, '10 boxes x 12 pieces', 9.2, 25, 0); 31 | INSERT INTO "products" VALUES(20, 'Sir Rodney''s Marmalade', 8, 3, '30 gift boxes', 81.0, 40, 0); 32 | INSERT INTO "products" VALUES(21, 'Sir Rodney''s Scones', 8, 3, '24 pkgs. x 4 pieces', 10.0, 3, 0); 33 | INSERT INTO "products" VALUES(22, 'Gustaf''s Knackebrod', 9, 5, '24 - 500 g pkgs.', 21.0, 104, 0); 34 | INSERT INTO "products" VALUES(23, 'Tunnbrod', 9, 9, '12 - 250 g pkgs.', 9.0, 9, 1); 35 | INSERT INTO "products" VALUES(24, 'Guarana Fantastica', 10, 1, '12 - 355 ml cans', 4.5, 20, 1); 36 | INSERT INTO "products" VALUES(25, 'NuNuCa Nu-Nougat-Creme', 11, 3, '20 - 450 g glasses', 14.0, 76, 0); 37 | INSERT INTO "products" VALUES(26, 'Gumbar Gummibarchen', 11, 3, '100 - 250 g bags', 31.23, 15, 0); 38 | INSERT INTO "products" VALUES(27, 'Schoggi Schokolade', 11, 3, '100 - 100 g pieces', 43.9, 49, 0); 39 | INSERT INTO "products" VALUES(28, 'Rossle Sauerkraut', 12, 7, '25 - 825 g cans', 45.6, 26, 1); 40 | INSERT INTO "products" VALUES(29, 'Thuringer Rostbratwurst', 12, 6, '50 bags x 30 sausgs.', 123.79, 0, 1); 41 | INSERT INTO "products" VALUES(30, 'Nord-Ost Matjeshering', 13, 8, '10 - 200 g glasses', 25.89, 10, 0); 42 | INSERT INTO "products" VALUES(31, 'Gorgonzola Telino', 14, 4, '12 - 100 g pkgs', 12.5, 0, 0); 43 | INSERT INTO "products" VALUES(32, 'Mascarpone Fabioli', 14, 4, '24 - 200 g pkgs.', 32.0, 9, 0); 44 | INSERT INTO "products" VALUES(33, 'Geitost', 15, 4, '500 g', 2.5, 112, 0); 45 | INSERT INTO "products" VALUES(34, 'Sasquatch Ale', 16, 1, '24 - 12 oz bottles', 14.0, 111, 0); 46 | INSERT INTO "products" VALUES(35, 'Steeleye Stout', 16, 1, '24 - 12 oz bottles', 18.0, 20, 0); 47 | INSERT INTO "products" VALUES(36, 'Inlagd Sill', 17, 8, '24 - 250 g jars', 19.0, 112, 0); 48 | INSERT INTO "products" VALUES(37, 'Gravad lax', 17, 8, '12 - 500 g pkgs.', 26.0, 11, 0); 49 | INSERT INTO "products" VALUES(38, 'Cote de Blaye', 18, 1, '12 - 75 cl bottles', 263.5, 17, 0); 50 | INSERT INTO "products" VALUES(39, 'Chartreuse verte', 1, 1, '750 cc per bottle', 18.0, 18, 0); 51 | INSERT INTO "products" VALUES(40, 'Boston Crab Meat', 8, 1, '24 - 4 oz tins', 18.4, 18.4, 1); 52 | INSERT INTO "products" VALUES(41, 'Jack''s New England Clam Chowder', 19, 8, '12 - 12 oz cans', 9.65, 85, 0); 53 | INSERT INTO "products" VALUES(42, 'Singaporean Hokkien Fried Mee', 20, 5, '32 - 1 kg pkgs.', 14.0, 26, 1); 54 | INSERT INTO "products" VALUES(43, 'Ipoh Coffee', 20, 1, '16 - 500 g tins', 46.0, 17, 0); 55 | INSERT INTO "products" VALUES(44, 'Gula Malacca', 20, 2, '20 - 2 kg bags', 19.45, 27, 0); 56 | INSERT INTO "products" VALUES(45, 'Rogede sild', 21, 8, '1k pkg.', 9.5, 5, 0); 57 | INSERT INTO "products" VALUES(46, 'Spegesild', 21, 8, '4 - 450 g glasses', 12.0, 95, 0); 58 | INSERT INTO "products" VALUES(47, 'Zaanse koeken', 22, 3, '10 - 4 oz boxes', 9.5, 36, 0); 59 | INSERT INTO "products" VALUES(48, 'Chocolade', 22, 3, '10 pkgs.', 12.75, 15, 0); 60 | INSERT INTO "products" VALUES(49, 'Maxilaku', 23, 3, '24 - 50 g pkgs.', 20.0, 10, 0); 61 | INSERT INTO "products" VALUES(50, 'Valkoinen suklaa', 23, 3, '12 - 100 g bars', 16.25, 65, 0); 62 | INSERT INTO "products" VALUES(51, 'Manjimup Dried Apples', 7, 3, '50 - 300 g pkgs.', 53.0, 53, 0); 63 | INSERT INTO "products" VALUES(52, 'Filo Mix1', 5, 3, '16 - 2 kg boxes', 7.0, 7, 0); 64 | INSERT INTO "products" VALUES(53, 'Perth Pasties', 24, 6, '48 pieces', 32.8, 0, 1); 65 | INSERT INTO "products" VALUES(54, 'Tourtiere', 25, 6, '16 pies', 7.45, 21, 0); 66 | INSERT INTO "products" VALUES(55, 'Pate chinois', 25, 6, '24 boxes x 2 pies', 24.0, 115, 0); 67 | INSERT INTO "products" VALUES(56, 'Gnocchi di nonna Alice', 26, 5, '24 - 250 g pkgs.', 38.0, 21, 0); 68 | INSERT INTO "products" VALUES(57, 'Ravioli Angelo', 26, 5, '24 - 250 g pkgs.', 19.5, 36, 0); 69 | INSERT INTO "products" VALUES(58, 'Escargots de Bourgogne', 27, 8, '24 pieces', 13.25, 62, 0); 70 | INSERT INTO "products" VALUES(59, 'Raclette Courdavault', 28, 4, '5 kg pkg.', 55.0, 79, 0); 71 | INSERT INTO "products" VALUES(60, 'Camembert Pierrot', 4, 3, '15 - 300 g rounds', 34.0, 34, 0); 72 | INSERT INTO "products" VALUES(61, 'Sirop d''erable', 29, 2, '24 - 500 ml bottles', 28.5, 113, 0); 73 | INSERT INTO "products" VALUES(62, 'Tarte au sucre', 29, 3, '48 pies', 49.3, 17, 0); 74 | INSERT INTO "products" VALUES(63, 'Vegie-spread', 7, 2, '15 - 625 g jars', 43.9, 24, 0); 75 | INSERT INTO "products" VALUES(64, 'Wimmers gute Semmelknodel', 5, 3, '20 bags x 4 pieces', 33.25, 33.25, 0); 76 | INSERT INTO "products" VALUES(65, 'Louisiana Fiery Hot Pepper Sauce', 2, 2, '32 - 8 oz bottles', 21.05, 76, 0); 77 | INSERT INTO "products" VALUES(66, 'Louisiana Hot Spiced Okra', 2, 2, '24 - 8 oz jars', 17.0, 4, 0); 78 | INSERT INTO "products" VALUES(67, 'Laughing Lumberjack Lager', 16, 1, '24 - 12 oz bottles', 14.0, 52, 0); 79 | INSERT INTO "products" VALUES(68, 'Scottish Longbreads', 8, 3, '10 boxes x 8 pieces', 12.5, 6, 0); 80 | INSERT INTO "products" VALUES(69, 'Gudbrandsdalsost', 15, 4, '10 kg pkg.', 36.0, 26, 0); 81 | INSERT INTO "products" VALUES(70, 'Outback Lager', 7, 1, '24 - 355 ml bottles', 15.0, 15, 0); 82 | INSERT INTO "products" VALUES(71, 'Flotemysost', 15, 4, '10 - 500 g pkgs.', 21.5, 26, 0); 83 | INSERT INTO "products" VALUES(72, 'Mozzarella di Giovanni', 14, 4, '24 - 200 g pkgs.', 34.8, 14, 0); 84 | INSERT INTO "products" VALUES(73, 'Rod Kaviar', 17, 8, '24 - 150 g jars', 15.0, 101, 0); 85 | INSERT INTO "products" VALUES(74, 'Longlife Tofu', 4, 7, '5 kg pkg.', 10.0, 4, 0); 86 | INSERT INTO "products" VALUES(75, 'Rhonbrau Klosterbier', 12, 1, '24 - 0.5 l bottles', 7.75, 125, 0); 87 | INSERT INTO "products" VALUES(76, 'Lakkalikoori', 23, 1, '500 ml', 18.0, 57, 0); 88 | INSERT INTO "products" VALUES(77, 'Original Frankfurter grune Sobe', 12, 2, '12 boxes', 13.0, 32, 0); 89 | INSERT INTO "products" VALUES(78, 'Pizza', 18, 1, 'package', 10.0, 0, 1); 90 | CREATE TABLE 'categories' ( 91 | 'category_id' INTEGER PRIMARY KEY, 92 | 'category' TEXT, 93 | 'description' TEXT, 94 | 'enable' BOOLEAN DEFAULT '1' 95 | ); 96 | INSERT INTO "categories" VALUES(1, 'Beverages', 'Soft drinks, coffees, teas, beers, and ales', 1); 97 | INSERT INTO "categories" VALUES(2, 'Condiments', 'Sweet and savory sauces, relishes, spreads, and seasonings', 1); 98 | INSERT INTO "categories" VALUES(3, 'Confections', 'Desserts, candies, and sweet breads', 1); 99 | INSERT INTO "categories" VALUES(4, 'Dairy Products', 'Cheeses', 1); 100 | INSERT INTO "categories" VALUES(5, 'Grains/Cereals', 'Breads, crackers, pasta, and cereal', 1); 101 | INSERT INTO "categories" VALUES(6, 'Meat/Poultry', 'Prepared meats', 1); 102 | INSERT INTO "categories" VALUES(7, 'Produce', 'Dried fruit and bean curd', 1); 103 | INSERT INTO "categories" VALUES(8, 'Seafood', 'Seaweed and fish', 1); 104 | INSERT INTO "categories" VALUES(9, 'No assigned', 'No assigned', 1); 105 | CREATE TABLE 'suppliers' ( 106 | 'supplier_id' INTEGER PRIMARY KEY, 107 | 'company' TEXT, 108 | 'enable' BOOLEAN DEFAULT '1' 109 | ); 110 | INSERT INTO "suppliers" VALUES(1, 'Exotic Liquids', 1); 111 | INSERT INTO "suppliers" VALUES(2, 'New Orleans Cajun Delights', 1); 112 | INSERT INTO "suppliers" VALUES(3, 'Grandma Kelly''s Homestead', 1); 113 | INSERT INTO "suppliers" VALUES(4, 'Tokyo Traders', 1); 114 | INSERT INTO "suppliers" VALUES(5, 'Cooperativa de Quesos ''Las Cabras''', 1); 115 | INSERT INTO "suppliers" VALUES(6, 'Mayumi''s', 1); 116 | INSERT INTO "suppliers" VALUES(7, 'Pavlova, Ltd.', 1); 117 | INSERT INTO "suppliers" VALUES(8, 'Specialty Biscuits, Ltd.', 1); 118 | INSERT INTO "suppliers" VALUES(9, 'PB Knckebrd AB', 1); 119 | INSERT INTO "suppliers" VALUES(10, 'Refrescos Americanas LTDA', 1); 120 | INSERT INTO "suppliers" VALUES(11, 'Heli Swaren GmbH & Co. KG', 1); 121 | INSERT INTO "suppliers" VALUES(12, 'Plutzer Lebensmittelgromrkte AG', 1); 122 | INSERT INTO "suppliers" VALUES(13, 'Nord-Ost-Fisch Handelsgesellschaft mbH', 1); 123 | INSERT INTO "suppliers" VALUES(14, 'Formaggi Fortini s.r.l.', 1); 124 | INSERT INTO "suppliers" VALUES(15, 'Norske Meierier', 1); 125 | INSERT INTO "suppliers" VALUES(16, 'Bigfoot Breweries', 1); 126 | INSERT INTO "suppliers" VALUES(17, 'Svensk Sjfda AB', 1); 127 | INSERT INTO "suppliers" VALUES(18, 'Aux joyeux ecclsiastiques', 1); 128 | INSERT INTO "suppliers" VALUES(19, 'New England Seafood Cannery', 1); 129 | INSERT INTO "suppliers" VALUES(20, 'Leka Trading', 1); 130 | INSERT INTO "suppliers" VALUES(21, 'Lyngbysild', 1); 131 | INSERT INTO "suppliers" VALUES(22, 'Zaanse Snoepfabriek', 1); 132 | INSERT INTO "suppliers" VALUES(23, 'Karkki Oy', 1); 133 | INSERT INTO "suppliers" VALUES(24, 'G''day, Mate', 1); 134 | INSERT INTO "suppliers" VALUES(25, 'Ma Maison', 1); 135 | INSERT INTO "suppliers" VALUES(26, 'Pasta Buttini s.r.l.', 1); 136 | INSERT INTO "suppliers" VALUES(27, 'Escargots Nouveaux', 1); 137 | INSERT INTO "suppliers" VALUES(28, 'Gai pturage', 1); 138 | INSERT INTO "suppliers" VALUES(29, 'Forts d''rables', 1); 139 | COMMIT; 140 | -------------------------------------------------------------------------------- /tools.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # ----------------------------------------------------------------------------- 3 | # authors: 1966bc 4 | # mailto: [giuseppecostanzi@gmail.com] 5 | # modify: hiems MMXXI 6 | # ------------------------------------------------------------------------------- 7 | import tkinter as tk 8 | from tkinter import messagebox 9 | from tkinter import ttk 10 | 11 | 12 | class Tools: 13 | """ 14 | Tools is a class to set, get some usefull things about app widgets. 15 | """ 16 | 17 | def __str__(self): 18 | return "class: {0}".format((self.__class__.__name__, )) 19 | 20 | def set_style(self, theme): 21 | """ 22 | Recive theme name and set style for all widgets. 23 | """ 24 | 25 | self.style = ttk.Style() 26 | 27 | self.style.theme_use(theme) 28 | 29 | self.style.configure(".", 30 | background=self.get_rgb(240, 240, 237), 31 | font=("TkFixedFont")) 32 | 33 | self.style.configure("App.TFrame") 34 | 35 | self.style.configure("Product.TEntry", 36 | foreground=self.get_rgb(0, 0, 255), 37 | background=self.get_rgb(255, 255, 255)) 38 | 39 | self.style.configure("Package.TEntry", 40 | foreground=self.get_rgb(255, 0, 0), 41 | background=self.get_rgb(255, 255, 255)) 42 | 43 | self.style.configure("App.TLabelframe", 44 | relief=tk.GROOVE, 45 | padding=2) 46 | 47 | self.style.configure("App.TButton", 48 | padding=5, 49 | border=1, 50 | relief=tk.RAISED) 51 | 52 | self.style.configure("App.TLabel", 53 | padding=2, 54 | anchor=tk.W) 55 | 56 | self.style.configure("App.TRadiobutton", 57 | padding=4) 58 | 59 | self.style.configure("App.TCombobox") 60 | 61 | self.style.configure("StatusBar.TLabel", 62 | padding=2, 63 | border=1, 64 | relief=tk.SUNKEN) 65 | 66 | self.style.map("Treeview", 67 | foreground=self.fixed_map("foreground"), 68 | background=self.fixed_map("background")) 69 | 70 | self.style.configure("Treeview.Heading", 71 | background=self.get_rgb(240, 240, 237), 72 | font=("TkHeadingFont", 10)) 73 | 74 | self.style.layout("Treeview", [("Treeview.treearea", {"sticky": "nswe"})]) 75 | 76 | self.style.configure("Mandatory.TLabel", 77 | foreground=self.get_rgb(0, 0, 255), 78 | background=self.get_rgb(255, 255, 255)) 79 | 80 | def get_rgb(self, r, g, b): 81 | """Translates an rgb tuple of int to a tkinter friendly color code""" 82 | return "#%02x%02x%02x" % (r, g, b) 83 | 84 | def center_me(self, container): 85 | """Center window on the screen""" 86 | x = (container.winfo_screenwidth() - container.winfo_reqwidth()) / 2 87 | y = (container.winfo_screenheight() - container.winfo_reqheight()) / 2 88 | container.geometry("+%d+%d" % (x, y)) 89 | 90 | 91 | def on_fields_control(self, container, title): 92 | """Ceck if all entry widget are empty 93 | Chek even if a value set in a combobox is legal""" 94 | 95 | msg = "Please fill all fields." 96 | 97 | for w in container.winfo_children(): 98 | for field in w.winfo_children(): 99 | if type(field) in(ttk.Entry, tk.Entry, ttk.Combobox): 100 | if not field.get(): 101 | messagebox.showwarning(title, msg, parent=container) 102 | field.focus() 103 | return 0 104 | elif type(field) == ttk.Combobox: 105 | if field.get() not in field.cget("values"): 106 | msg = "You can choice only a value of the list." 107 | messagebox.showwarning(container.master.title(), msg, parent=container) 108 | field.focus() 109 | return 0 110 | 111 | def get_tree(self, container, cols, size=None, show=None): 112 | """Get a treeview""" 113 | #this is a patch because with tkinter version 114 | #with Tk 8.6.9 the color assignment with tags dosen't work 115 | #https://bugs.python.org/issue36468 116 | #style = ttk.Style() 117 | 118 | if size is not None: 119 | self.style.configure("Treeview", 120 | highlightthickness=0, 121 | bd=0, 122 | font=("TkHeadingFont", size)) # Modify the font of the body 123 | else: 124 | pass 125 | 126 | headers = [] 127 | 128 | for col in cols: 129 | headers.append(col[1]) 130 | del headers[0] 131 | 132 | if show is not None: 133 | w = ttk.Treeview(container, show=show) 134 | 135 | else: 136 | w = ttk.Treeview(container,) 137 | 138 | w["columns"] = headers 139 | 140 | for col in cols: 141 | w.heading(col[0], text=col[1], anchor=col[2],) 142 | w.column(col[0], anchor=col[2], stretch=col[3], minwidth=col[4], width=col[5]) 143 | 144 | sb = ttk.Scrollbar(container) 145 | sb.configure(command=w.yview) 146 | w.configure(yscrollcommand=sb.set) 147 | 148 | w.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) 149 | sb.pack(fill=tk.Y, expand=1) 150 | 151 | return w 152 | 153 | def fixed_map(self, option): 154 | 155 | style = ttk.Style() 156 | # Fix for setting text colour for Tkinter 8.6.9 157 | # From: https://core.tcl.tk/tk/info/509cafafae 158 | # 159 | # Returns the style map for 'option' with any styles starting with 160 | # ('!disabled', '!selected', ...) filtered out. 161 | 162 | # style.map() returns an empty list for missing options, so this 163 | # should be future-safe. 164 | return [elm for elm in style.map("Treeview", query_opt=option) if 165 | elm[:2] != ("!disabled", "!selected")] 166 | 167 | 168 | def get_validate_integer(self, caller): 169 | return (caller.register(self.validate_integer), 170 | "%d", "%i", "%P", "%s", "%S", "%v", "%V", "%W") 171 | 172 | def get_validate_float(self, caller): 173 | return (caller.register(self.validate_float), 174 | "%d", "%i", "%P", "%s", "%S", "%v", "%V", "%W") 175 | 176 | def validate_integer(self, action, index, value_if_allowed, 177 | prior_value, text, validation_type, 178 | trigger_type, widget_name): 179 | 180 | # action=1 -> insert 181 | if action == "1": 182 | if text in "0123456789": 183 | try: 184 | int(value_if_allowed) 185 | return True 186 | except ValueError: 187 | return False 188 | else: 189 | return False 190 | else: 191 | return True 192 | 193 | def validate_float(self, action, index, value_if_allowed, 194 | prior_value, text, validation_type, 195 | trigger_type, widget_name): 196 | 197 | # action=1 -> insert 198 | if action == "1": 199 | if text in "0123456789.-+": 200 | try: 201 | float(value_if_allowed) 202 | return True 203 | except ValueError: 204 | return False 205 | else: 206 | return False 207 | else: 208 | return True 209 | 210 | def main(): 211 | 212 | foo = Tools() 213 | print(foo) 214 | input("end") 215 | 216 | if __name__ == "__main__": 217 | main() 218 | --------------------------------------------------------------------------------