code-organization

Trying to grasp the point of putting frames and widgets in classes for tkinter

允我心安 提交于 2020-06-08 15:06:21
问题 As the question states, I can't seem to fully grasp the point of using classes with tkinter. I have read through a decent number of different sites but I keep getting search results on how to create and use classes, but none so far have been able to get through to me. I've even scoured through the suggested questions while asking this one. The closest I've come to understanding is Bryan's explanation on this answer to the question Why use classes when programming a tkinter gui? But still, I

Avoiding repeat of code after loop?

会有一股神秘感。 提交于 2020-01-01 07:55:08
问题 I often end up writing a bit of code twice when using a loops. For example, while going over the Udacity computer science course, I wrote the code (for a function to find the most sequentially repeated element): def longest_repetition(l): if not l: return None most_reps = count = 0 longest = prv = None for i in l: if i == prv: count += 1 else: if count > most_reps: longest = prv most_reps = count count = 1 prv = i if count > most_reps: longest = prv return longest In this case, I'm checking

Organizing GUI code

邮差的信 提交于 2020-01-01 02:35:26
问题 My question has two parts: Does anyone have any tips or references to some documentation on the web about how to write GUI code that is easy to read, write, and maintain? Example. I find that the more extensive my GUI forms become, I end up with a long list of fairly short event handler methods. If I try to add any private helper methods, they just get lost in the shuffle, and I constantly have to scroll around the page to follow a single line of thought. How can I easily manage settings

Folder and file organization for Python development

青春壹個敷衍的年華 提交于 2019-12-30 00:59:50
问题 What is the best way to organize code that belongs to the same project in a Python development environment? What are the do and donts of Python project organization? Do you separate each class in a file? Project A Classes "subsystem1" class1 class2 subsystem1Module "subsystem2" "utils" "etc" Tests Whatever etc? Any suggestions? Oh, and please describe what are the (possible) problems of each type of organization. What are considered best practices for organizing Python code? 回答1: Some

jQuery and “Organized Code”

半腔热情 提交于 2019-12-29 02:33:07
问题 I've been struggling lately with understanding the best way to organize jQuery code. I asked another question earlier and I don't think I was specific enough (found in this question here). My problem is that the richer you make an application, the quicker your client side gets out of control. Consider this situation... //Let's start some jQuery $(function() { var container = $("#inputContainer"); //Okay let's list text fields that can be updated for(var i=0; i < 5; i++) { //okay let's add an

Consolidating messy routes in Rails 4. How to organize routes to not point urls to static links?

◇◆丶佛笑我妖孽 提交于 2019-12-24 13:31:16
问题 Here comes a rails nub organizational question: What exists: A "Railsy" link would look something like this (in slim) span a href= signout_path signout_path correspond to AuthController#signout . So, in my applications there's several types of users - Firefighters, Chiefs and Captains. Each one has very similar routes: /dashboard /dashboard/:date ( this is in case they want to see a previous date; same dashboard, different data in the controller ) /account /account/update /entry/view /entry

Java swing - Where should the ActionListener go?

99封情书 提交于 2019-12-24 01:37:08
问题 By convention, where should the ActionListener for a user inteface go? I have several options but none of them seem quite right. Shorthand: GUI - main class that contains all the JPanels/displayable objects Logic - main class that handles application logic I could in-line declare a new ActionListener in GUI, store it, and then it/pass its pointer around to where it's needed. I could make GUI itself implement ActionListener and pass a reference to itself to where it's needed. I could in-line

A bit lost with organizing real world application code in asp.net mvc

妖精的绣舞 提交于 2019-12-23 17:52:30
问题 I have the following real world scenario, somewhat simplified for the sake of this example I have an object, let's call it Movie which will consist of several attributes, such as release date actors (array) genre rating I need to be able to have a form where a new movie can be entered, with the following elements on the form: date calendar drop down list with actors grop down list with genres rating field with stars What would be a clear consice way to organise my code using asp.net mvc,

HTML site development: div's vs ul's for navigation and menus

泪湿孤枕 提交于 2019-12-23 15:22:11
问题 I'm working on developing a Web 2.0 site, and I've been looking at how sites deal with menus and nav-bars. Many sites (like twitter) use UL's whereas sites such as stackoverflow use div's that are ID's containing links. Is there an advantage to not using UL's other than it eliminates some IE bugs? is there an advantage to using UL's? Thanks! 回答1: I personally use ul/li for all of my menu needs as it makes it clear to even an unstyled browser (Links for example) that it is a menu of some sort